diff --git a/tinyx/build.sh b/tinyx/build.sh index ae77c28..79ae3b9 100755 --- a/tinyx/build.sh +++ b/tinyx/build.sh @@ -389,6 +389,33 @@ build_suckless() { } +build_micropolis() { + b_log "tinyx: building micropolis" + + ref="b0c5a3f495ebabbc51d5e45dac948d8e40fc53ee" + short_ref=$(echo ${ref} | cut -c -6) + archive_filename="${ref}.tar.gz" + + PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/micropolis/${short_ref}" + b_port_download "https://github.com/SimHacker/micropolis/archive/" "${archive_filename}" + + extract_sources + + b_port_apply_patches "${PREFIX_PORT_SRC}" "micropolis/${short_ref}" + + set +e + for i in {1..3} # If you run make exactly 3 times, micropolis will compile... + do + make -C "${PREFIX_PORT_SRC}/micropolis-activity" PREFIX="${PREFIX_A}" + done + set -e + + $STRIP -o "${PREFIX_PROG_STRIPPED}/Micropolis" "${PREFIX_PORT_SRC}/micropolis-activity/src/sim/sim" + + b_install "${PREFIX_PORTS_INSTALL}/Micropolis" /bin +} + + # Call ordering is important here build_tinyxlib build_a_lib libfontenc 1.1.8 @@ -411,5 +438,6 @@ build_x11_app xsetroot 1.1.1 build_x11_app xinit 1.3.3 build_x11_app xrdb 1.2.2 build_x11_app xgc 1.0.6 +# build_micropolis rm -rf "$TMP_DIR" diff --git a/tinyx/patches/micropolis/b0c5a3/01-micropolis.patch b/tinyx/patches/micropolis/b0c5a3/01-micropolis.patch new file mode 100644 index 0000000..f98df65 --- /dev/null +++ b/tinyx/patches/micropolis/b0c5a3/01-micropolis.patch @@ -0,0 +1,292 @@ +diff -ruN a/micropolis-activity/res/micropolis.tcl b/micropolis-activity/res/micropolis.tcl +--- a/micropolis-activity/res/micropolis.tcl 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/res/micropolis.tcl 2024-08-29 10:58:30.934849614 +0200 +@@ -128,7 +128,7 @@ + set HomeDir "" + set ResourceDir "" + set HostName "" +-set LocalHostName "[exec hostname]" ++set LocalHostName "phoenix" + set SaveCityWin "" + set MapHistory {} + set MapHistoryNum -1 +diff -ruN a/micropolis-activity/src/sim/headers/sim.h b/micropolis-activity/src/sim/headers/sim.h +--- a/micropolis-activity/src/sim/headers/sim.h 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/sim/headers/sim.h 2024-08-29 10:39:07.930492735 +0200 +@@ -121,8 +121,6 @@ + #endif + #endif + +-#include +-#include + #include + #include + #include +diff -ruN a/micropolis-activity/src/sim/makefile b/micropolis-activity/src/sim/makefile +--- a/micropolis-activity/src/sim/makefile 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/sim/makefile 2024-08-29 10:39:07.930492735 +0200 +@@ -1,12 +1,12 @@ +-XINCLUDE = /usr/X11R6/include/X11 +-XLIB = /usr/X11R6/lib ++XINCLUDE = $(PREFIX_H)/X11 ++XLIB = $(PREFIX_A) + TCLHOME = ../tcl + TKHOME = ../tk + TCLXHOME = ../tclx + TCLLIBRARY = /usr/local/lib/tcl + TKLIBRARY = /usr/local/lib/tk + +-CC = gcc ++# CC = gcc + + OPTFLAGS = -O3 + #OPTFLAGS = -g +@@ -14,9 +14,9 @@ + #DEFINES = -DIS_LINUX -DCAM -DNET + DEFINES = -DIS_LINUX -DNO_AIRCRASH + +-CFLAGS = $(OPTFLAGS) $(DEFINES) ++CFLAGS += $(OPTFLAGS) $(DEFINES) + +-LDFLAGS = -L/usr/X11/lib -L/usr/X11R6/lib ++LDFLAGS += -L$(PREFIX_A) + + INSTALL = install -s + +@@ -28,15 +28,15 @@ + -I$(TCLXHOME)/src \ + -I$(TKHOME) + +-CPPFLAGS = $(INCLUDES) ++CPPFLAGS += $(INCLUDES) + + LIBS = $(TCLXHOME)/libtk.a \ + $(TCLXHOME)/libtcl.a \ + -lm \ + -L$(XLIB) \ +- -lX11 \ +- -lXext \ +- -lXpm ++ -l:libXext.a \ ++ -l:libXpm.a \ ++ -l:libX11.a + + SRCS = \ + sim.c \ +diff -ruN a/micropolis-activity/src/sim/s_fileio.c b/micropolis-activity/src/sim/s_fileio.c +--- a/micropolis-activity/src/sim/s_fileio.c 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/sim/s_fileio.c 2024-08-29 10:39:07.930492735 +0200 +@@ -486,12 +486,12 @@ + CityFileName = (char *)ckalloc(strlen(filename) + 1); + strcpy(CityFileName, filename); + +- if (cp = (char *)rindex(filename, '.')) ++ if (cp = (char *)strrchr(filename, '.')) + *cp = 0; + #ifdef MSDOS +- if (cp = (char *)rindex(filename, '\\')) ++ if (cp = (char *)strrchr(filename, '\\')) + #else +- if (cp = (char *)rindex(filename, '/')) ++ if (cp = (char *)strrchr(filename, '/')) + #endif + cp++; + else +@@ -579,12 +579,12 @@ + strcpy(CityFileName, filename); + + if (saveFile(CityFileName)) { +- if (cp = (char *)rindex(filename, '.')) ++ if (cp = (char *)strrchr(filename, '.')) + *cp = 0; + #ifdef MSDOS +- if (cp = (char *)rindex(filename, '\\')) ++ if (cp = (char *)strrchr(filename, '\\')) + #else +- if (cp = (char *)rindex(filename, '/')) ++ if (cp = (char *)strrchr(filename, '/')) + #endif + cp++; + else +diff -ruN a/micropolis-activity/src/sim/w_x.c b/micropolis-activity/src/sim/w_x.c +--- a/micropolis-activity/src/sim/w_x.c 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/sim/w_x.c 2024-08-29 10:39:07.932501038 +0200 +@@ -71,6 +71,8 @@ + #endif + int GotXError; + ++#define MSDOS ++ + + unsigned char ColorIntensities[] = { + /* COLOR_WHITE */ 255, +diff -ruN a/micropolis-activity/src/tcl/makefile b/micropolis-activity/src/tcl/makefile +--- a/micropolis-activity/src/tcl/makefile 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tcl/makefile 2024-08-29 10:39:07.933505190 +0200 +@@ -23,10 +23,10 @@ + # + + TCL_LIBRARY = /usr/local/lib/tcl ++# ++# CC = gcc + +-CC = gcc +- +-CFLAGS = -O3 -I. -DTCL_LIBRARY=\"${TCL_LIBRARY}\" -DIS_LINUX ++CFLAGS += -O3 -I. -DTCL_LIBRARY=\"${TCL_LIBRARY}\" -DIS_LINUX + #CFLAGS = -g -I. -DTCL_LIBRARY=\"${TCL_LIBRARY}\" -DIS_LINUX + + GENERIC_OBJS = \ +diff -ruN a/micropolis-activity/src/tcl/tclglob.c b/micropolis-activity/src/tcl/tclglob.c +--- a/micropolis-activity/src/tcl/tclglob.c 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tcl/tclglob.c 2024-08-29 10:39:07.934509341 +0200 +@@ -493,7 +493,7 @@ + strcat(curBuf, p); + #ifndef MSDOS + if (fromPw) { +- endpwent(); ++ // endpwent(); + } + #endif + return curBuf; +diff -ruN a/micropolis-activity/src/tclx/config/linux b/micropolis-activity/src/tclx/config/linux +--- a/micropolis-activity/src/tclx/config/linux 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tclx/config/linux 2024-08-29 10:39:07.935513493 +0200 +@@ -2,9 +2,9 @@ + # Linux and also Mac OS/X for that matter. + #------------------------------------------------------------------------------ + # +-SYS_DEP_FLAGS=-DTCL_HAVE_SETLINEBUF -DTCL_32_BIT_RANDOM -DTCL_POSIX_SIG -DTCL_TM_GMTOFF ++SYS_DEP_FLAGS=-DTCL_32_BIT_RANDOM -DTCL_POSIX_SIG -DTCL_TIMEZONE_VAR -DTCL_IEEE_FP_MATH -DTCL_NO_ITIMER + LIBS=-lm + RANLIB_CMD=ranlib + MCS_CMD=true +-TCL_TK_LIBS= -L/usr/X11R6/lib -lX11 -lm -lXpm ++TCL_TK_LIBS= -L$(PREFIX_A) -lm -l:libXpm.a -l:libX11.a + TCL_MAN_SEPARATOR= +diff -ruN a/micropolis-activity/src/tclx/config.mk b/micropolis-activity/src/tclx/config.mk +--- a/micropolis-activity/src/tclx/config.mk 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tclx/config.mk 2024-08-29 10:39:07.935513493 +0200 +@@ -53,14 +53,14 @@ + TCL_TK_SHELL=wish + TCL_TK_DIR=../tk + TK_LIBRARY=/usr/local/lib/tk +-XPM_LIBS=-L/usr/X11R6/lib -lXpm ++XPM_LIBS=-L$(PREFIX_A) -l:libXpm.a -l:libX11.a + + #------------------------------------------------------------------------------ + # Compiler debug/optimization/profiling flag to use. Not that if debugging or + # profiling is enabled, the DO_STRIPPING option below must be disabled. + # + +-CC=gcc ++# CC=gcc + + OPTIMIZE_FLAG=-O3 -DIS_LINUX + #OPTIMIZE_FLAG=-g -DIS_LINUX +@@ -212,6 +212,8 @@ + TK_MAN_CMD_SECTION=1 + TK_MAN_FUNC_SECTION=3 + ++LIBS=-l:libX11.a ++ + + #.............................................................................. + # The rest of the manual page install options are set in the system dependent +diff -ruN a/micropolis-activity/src/tclx/makefile b/micropolis-activity/src/tclx/makefile +--- a/micropolis-activity/src/tclx/makefile 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tclx/makefile 2024-08-29 10:39:07.935513493 +0200 +@@ -30,7 +30,7 @@ + MADE.FILES=ucbsrc/made.tmp ossupp/made.tmp src/made.tmp + TKMADE.FILES=tkucbsrc/made.tmp + +-CFLAGS= $(OPTIMIZE_FLAG) $(XCFLAGS) -I$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \ ++CFLAGS+= $(OPTIMIZE_FLAG) $(XCFLAGS) -I$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \ + $(SYS_DEP_FLAGS) + + #------------------------------------------------------------------------------ +diff -ruN a/micropolis-activity/src/tclx/ossupp/makefile b/micropolis-activity/src/tclx/ossupp/makefile +--- a/micropolis-activity/src/tclx/ossupp/makefile 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tclx/ossupp/makefile 2024-08-29 10:39:07.935513493 +0200 +@@ -22,7 +22,7 @@ + + #------------------------------------------------------------------------------ + +-CFLAGS=$(OPTIMIZE_FLAG) $(XCFLAGS) -I../$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \ ++CFLAGS+=$(OPTIMIZE_FLAG) $(XCFLAGS) -I../$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \ + $(SYS_DEP_FLAGS) $(SUPPORT_FLAGS) + + #------------------------------------------------------------------------------ +diff -ruN a/micropolis-activity/src/tclx/src/makefile b/micropolis-activity/src/tclx/src/makefile +--- a/micropolis-activity/src/tclx/src/makefile 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tclx/src/makefile 2024-08-29 10:39:07.935513493 +0200 +@@ -25,7 +25,7 @@ + + #------------------------------------------------------------------------------ + +-CFLAGS= $(OPTIMIZE_FLAG) $(XCFLAGS) -I../$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \ ++CFLAGS+= $(OPTIMIZE_FLAG) $(XCFLAGS) -I../$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \ + $(SYS_DEP_FLAGS) + + #------------------------------------------------------------------------------ +diff -ruN a/micropolis-activity/src/tclx/tksrc/makefile b/micropolis-activity/src/tclx/tksrc/makefile +--- a/micropolis-activity/src/tclx/tksrc/makefile 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tclx/tksrc/makefile 2024-08-29 10:39:07.938525948 +0200 +@@ -23,7 +23,7 @@ + + #------------------------------------------------------------------------------ + +-CFLAGS= $(OPTIMIZE_FLAG) $(XCFLAGS) -I$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) ++CFLAGS+= $(OPTIMIZE_FLAG) $(XCFLAGS) -I$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) + + #------------------------------------------------------------------------------ + +diff -ruN a/micropolis-activity/src/tclx/tkucbsrc/makefile b/micropolis-activity/src/tclx/tkucbsrc/makefile +--- a/micropolis-activity/src/tclx/tkucbsrc/makefile 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tclx/tkucbsrc/makefile 2024-08-29 10:39:07.938525948 +0200 +@@ -23,7 +23,7 @@ + + #------------------------------------------------------------------------------ + +-CFLAGS= $(OPTIMIZE_FLAG) $(XCFLAGS) -I../src -I../$(TCL_TK_DIR) \ ++CFLAGS+= $(OPTIMIZE_FLAG) $(XCFLAGS) -I../src -I../$(TCL_TK_DIR) \ + -I../$(TCL_UCB_DIR) -I$(XHOME)/include \ + $(MEM_DEBUG_FLAGS) $(SYS_DEP_FLAGS) \ + -DTK_VERSION=\"2.2/\" +diff -ruN a/micropolis-activity/src/tclx/ucbsrc/makefile b/micropolis-activity/src/tclx/ucbsrc/makefile +--- a/micropolis-activity/src/tclx/ucbsrc/makefile 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tclx/ucbsrc/makefile 2024-08-29 10:39:07.938525948 +0200 +@@ -24,7 +24,7 @@ + + #------------------------------------------------------------------------------ + +-CFLAGS=$(OPTIMIZE_FLAG) $(XCFLAGS) -I../$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \ ++CFLAGS+=$(OPTIMIZE_FLAG) $(XCFLAGS) -I../$(TCL_UCB_DIR) $(MEM_DEBUG_FLAGS) \ + $(SYS_DEP_FLAGS) + + #------------------------------------------------------------------------------ +diff -ruN a/micropolis-activity/src/tk/makefile b/micropolis-activity/src/tk/makefile +--- a/micropolis-activity/src/tk/makefile 2015-03-15 15:22:19.000000000 +0100 ++++ b/micropolis-activity/src/tk/makefile 2024-08-29 10:39:07.941538403 +0200 +@@ -27,16 +27,16 @@ + # switch unless your library is in a non-standard place. + # + +-CC = gcc ++# 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 -DIS_LINUX + #CFLAGS = -I. -I$(XINCLUDE) -I$(TCL_DIR) -g -DTK_VERSION=\"2.3\" -DUSE_XPM3 -DIS_LINUX + + TCL_DIR = ../tcl +-XINCLUDE = /usr/X11R6/include/X11 +-XLIB = -L/usr/X11R6/lib -lX11 -lXpm ++XINCLUDE = $(PREFIX_H)/X11 ++XLIB = -L$(PREFIX_A) -l:libXpm.a -l:libX11.a + +-LIBS = libtk.a $(TCL_DIR)/libtcl.a ++LIBS += libtk.a $(TCL_DIR)/libtcl.a + LINKS = $(LIBS) + + WIDGOBJS = \ diff --git a/tinyx/patches/tinyx/eed490/12-colors-fix.patch b/tinyx/patches/tinyx/eed490/12-colors-fix.patch new file mode 100644 index 0000000..a05f933 --- /dev/null +++ b/tinyx/patches/tinyx/eed490/12-colors-fix.patch @@ -0,0 +1,147 @@ +diff -ruN a/kdrive/fbdev/fbdev.c b/kdrive/fbdev/fbdev.c +--- a/kdrive/fbdev/fbdev.c 2024-08-21 12:36:43.433667825 +0200 ++++ b/kdrive/fbdev/fbdev.c 2024-08-29 13:35:37.289274844 +0200 +@@ -33,7 +33,7 @@ + void refresher(void *arg) { + graph_t* g = (graph_t*) arg; + while (1) { +- usleep(12588); // ~70Hz ++ usleep(33333); // ~30Hz + graph_commit(g); + } + } +@@ -100,7 +100,7 @@ + FatalError("failed to initialize graphics adapter: %s", strerror(k)); + } + +- if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_70Hz)) < 0) { ++ if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_DEFFREQ)) < 0) { + FatalError("failed to set graphics mode: %d", k); + } + +@@ -134,7 +134,6 @@ + return TRUE; + } + +-#if 0 + static Pixel fbdevMakeContig(Pixel orig, Pixel others) + { + Pixel low; +@@ -147,6 +146,7 @@ + return orig; + } + ++#if 0 + static Bool fbdevModeSupported(KdScreenInfo * screen, const KdMonitorTiming * t) + { + return TRUE; +@@ -328,7 +328,6 @@ + screen->width = priv->g.width; + screen->height = priv->g.height; + screen->rate = 30; +- screen->fb.depth = depth; + + /* Calculate line_length if it's zero */ + if (!priv->line_length) +@@ -343,6 +342,32 @@ + screen->fb.blueMask = Mask(0,offset); + screen->fb.bitsPerPixel = priv->bits_per_pixel; + ++ screen->fb.redMask = fbdevMakeContig(screen->fb.redMask, ++ screen->fb. ++ greenMask | screen-> ++ fb.blueMask); ++ ++ screen->fb.greenMask = ++ fbdevMakeContig(screen->fb.greenMask, ++ screen->fb.redMask | screen->fb. ++ blueMask); ++ ++ screen->fb.blueMask = fbdevMakeContig(screen->fb.blueMask, ++ screen->fb.redMask | ++ screen->fb. ++ greenMask); ++ ++ Pixel allbits; ++ ++ allbits = ++ screen->fb.redMask | screen->fb.greenMask | screen-> ++ fb.blueMask; ++ depth = priv->bits_per_pixel; ++ while (depth && !(allbits & (1 << (depth - 1)))) ++ depth--; ++ ++ screen->fb.depth = depth; ++ + return fbdevMapFramebuffer(screen); + } + +@@ -362,6 +387,7 @@ + return TRUE; + } + ++#if 0 + static void *fbdevWindowLinear(ScreenPtr pScreen, + CARD32 row, + CARD32 offset, int mode, CARD32 * size, void *closure) +@@ -374,6 +400,7 @@ + *size = priv->line_length; + return (CARD8 *) priv->fb + row * priv->line_length + offset; + } ++#endif + + static Bool fbdevMapFramebuffer(KdScreenInfo * screen) + { +@@ -625,26 +652,21 @@ + + static Bool fbdevCreateColormap(ColormapPtr pmap) + { +- ScreenPtr pScreen = pmap->pScreen; + VisualPtr pVisual; + int i; + int nent; +- xColorItem *pdefs; ++ int val; + + pVisual = pmap->pVisual; + nent = pVisual->ColormapEntries; +- pdefs = malloc(nent * sizeof(xColorItem)); +- if (!pdefs) +- return FALSE; +- for (i = 0; i < nent; i++) +- pdefs[i].pixel = i; +- fbdevGetColors(pScreen, nent, pdefs); ++ printf("%d\n", nent); ++ + for (i = 0; i < nent; i++) { +- pmap->red[i].co.local.red = pdefs[i].red; +- pmap->green[i].co.local.green = pdefs[i].green; +- pmap->blue[i].co.local.blue = pdefs[i].blue; ++ val = i * 65535 / ((1 << 8) - 1); ++ pmap->red[i].co.local.red = val; ++ pmap->green[i].co.local.green = val; ++ pmap->blue[i].co.local.blue = val; + } +- free(pdefs); + return TRUE; + } + +@@ -782,6 +804,7 @@ + void fbdevGetColors(ScreenPtr pScreen, int n, xColorItem * pdefs) + { + int p; ++#if 0 + int k; + int min, max; + +@@ -793,8 +816,10 @@ + if (pdefs[k].pixel > max) + max = pdefs[k].pixel; + } ++#endif + while (n--) { + p = pdefs->pixel; ++ // TODO + pdefs->red = pdefs->green = pdefs->blue = p; + pdefs++; + }