diff --git a/tinyx/build.sh b/tinyx/build.sh index 36fbaf5..2db971e 100755 --- a/tinyx/build.sh +++ b/tinyx/build.sh @@ -134,6 +134,7 @@ build_tinyxlib() { PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/tinyxlib/${short_ref}" b_port_download "https://github.com/idunham/tinyxlib/archive/" "${archive_filename}" + # TODO move make outside of reconfigure block if should_reconfigure "tinyxlib/${short_ref}"; then extract_sources @@ -163,7 +164,7 @@ build_tinyxlib() { build_a_lib() { libname="$1" version="$2" - configure_opts="${@:3}" + configure_opts=${@:3} b_log "tinyx: building ${libname}" @@ -179,7 +180,7 @@ build_a_lib() { b_port_apply_patches "${PREFIX_PORT_SRC}" "${libname}/${version}" if [ ! -f "${PREFIX_PORT_SRC}/config.status" ]; then - exec_configure "${configure_opts}" + exec_configure ${configure_opts} fi mark_as_configured "${libname}/${version}" @@ -282,20 +283,91 @@ build_tinywm() { b_install "${PREFIX_PORTS_INSTALL}/tinywm" /bin } +build_x11_app() { + appname="$1" + version="$2" + configure_opts=${@:3} + + b_log "tinyx: building ${appname}" + + archive_filename="${appname}-${version}.tar.gz" + + PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/${appname}/${version}" + + b_port_download "https://www.x.org/archive/individual/app/" "${archive_filename}" + + if should_reconfigure "${appname}/${version}"; then + extract_sources + + b_port_apply_patches "${PREFIX_PORT_SRC}" "${appname}/${version}" + + if [ ! -f "${PREFIX_PORT_SRC}/config.status" ]; then + exec_configure ${configure_opts} + fi + + # FIXME: this is brutal, see build_tinyx note + find . -name 'Makefile' -print0 | xargs -0 sed -i 's/ -lXaw7/ -l:libXaw.a/g;s/ -lXt/ -l:libXt.a/g;s/ -lX11/ -l:libXmu.a -l:libXext.a -l:libSM.a -l:libICE.a -l:libXdmcp.a -l:libXpm.a -l:libX11.a/g' + + mark_as_configured "${appname}/${version}" + fi + + make -C "${PREFIX_PORT_SRC}" + + $STRIP -o "${PREFIX_PROG_STRIPPED}/${appname}" "${PREFIX_PORT_SRC}/${appname}" + + b_install "${PREFIX_PORTS_INSTALL}/${appname}" /bin +} + + +build_xedit() { + b_log "tinyx: building xedit" + + version="1.2.4" + archive_filename="xedit-${version}.tar.gz" + PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/xedit/${version}" + + b_port_download "https://www.x.org/archive/individual/app/" "${archive_filename}" + + if should_reconfigure "xedit/${version}"; then + extract_sources + + b_port_apply_patches "${PREFIX_PORT_SRC}" "xedit/${version}" + + if [ ! -f "${PREFIX_PORT_SRC}/config.status" ]; then + # exec_configure --with-lispdir="${PREFIX_A}/xedit/lsp" --with-appdefaultdir="$TMP_DIR" --bindir="$TMP_DIR" + exec_configure --with-lispdir="/etc/X11/xedit/lsp" --with-appdefaultdir="/etc/X11/app-defaults" --bindir="$TMP_DIR" + fi + + # # FIXME: this is brutal, see build_tinyx note + find . -name 'Makefile' -print0 | xargs -0 sed -i 's/ -lXaw7/ -l:libXaw.a/g;s/ -lXt/ -l:libXt.a/g;s/ -lX11/ -l:libXmu.a -l:libXext.a -l:libSM.a -l:libICE.a -l:libXdmcp.a -l:libXpm.a -l:libX11.a/g' + + mark_as_configured "xedit/${version}" + fi + + make -C "${PREFIX_PORT_SRC}" + # make -C "${PREFIX_PORT_SRC}" install_sh="" install + + $STRIP -o "${PREFIX_PROG_STRIPPED}/xedit" "${PREFIX_PORT_SRC}/xedit" + + # TODO: install app-defaults + + b_install "${PREFIX_PORTS_INSTALL}/xedit" /bin +} -build_xmessage() { - b_log "tinyx: building xmessage" +# requires yacc +build_twm() { + b_log "tinyx: building twm" - version="1.0.7" - archive_filename="xmessage-${version}.tar.gz" - PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/xmessage/${version}" + version="1.0.12" + archive_filename="twm-${version}.tar.gz" + PREFIX_PORT_SRC="${PREFIX_PORT_BUILD}/twm/${version}" b_port_download "https://www.x.org/archive/individual/app/" "${archive_filename}" - if should_reconfigure "xmessage/${version}"; then + if should_reconfigure "twm/${version}"; then extract_sources - b_port_apply_patches "${PREFIX_PORT_SRC}" "xmessage/${version}" + b_port_apply_patches "${PREFIX_PORT_SRC}" "twm/${version}" if [ ! -f "${PREFIX_PORT_SRC}/config.status" ]; then exec_configure @@ -304,14 +376,14 @@ build_xmessage() { # FIXME: this is brutal, see build_tinyx note find . -name 'Makefile' -print0 | xargs -0 sed -i 's/ -lXaw7/ -l:libXaw.a/g;s/ -lXt/ -l:libXt.a/g;s/ -lX11/ -l:libXmu.a -l:libXext.a -l:libSM.a -l:libICE.a -l:libXdmcp.a -l:libXpm.a -l:libX11.a/g' - mark_as_configured "xmessage/${version}" + mark_as_configured "twm/${version}" fi make -C "${PREFIX_PORT_SRC}" - $STRIP -o "${PREFIX_PROG_STRIPPED}/xmessage" "${PREFIX_PORT_SRC}/xmessage" + $STRIP -o "${PREFIX_PROG_STRIPPED}/twm" "${PREFIX_PORT_SRC}/src/twm" - b_install "${PREFIX_PORTS_INSTALL}/xmessage" /bin + b_install "${PREFIX_PORTS_INSTALL}/twm" /bin } @@ -349,8 +421,12 @@ build_tinyx build_tinywm build_ico -build_xmessage build_suckless st 0.2 # st compiles, but doesn't work yet build_suckless dwm 5.1 +build_x11_app xmessage 1.0.7 +build_x11_app xclock 1.1.1 --without-xft --without-xkb +build_x11_app xeyes 1.1.1 --without-xrender +build_xedit +build_twm rm -rf "$TMP_DIR" diff --git a/tinyx/patches/tinyx/10-vga.patch b/tinyx/patches/tinyx/10-vga.patch new file mode 100644 index 0000000..5ec64a9 --- /dev/null +++ b/tinyx/patches/tinyx/10-vga.patch @@ -0,0 +1,39 @@ +diff -ruN a/kdrive/fbdev/fbdev.c b/kdrive/fbdev/fbdev.c +--- a/kdrive/fbdev/fbdev.c 2024-08-19 09:44:57.484385862 +0200 ++++ b/kdrive/fbdev/fbdev.c 2024-08-19 09:57:33.218184783 +0200 +@@ -28,6 +28,15 @@ + #include + + #include ++#include ++ ++void refresher(void *arg) { ++ graph_t* g = (graph_t*) arg; ++ while (1) { ++ usleep(33333); // ~30Hz ++ graph_commit(g); ++ } ++} + + extern int KdTsPhyScreen; + +@@ -92,7 +101,7 @@ + FatalError("failed to initialize graphics adapter: %s", strerror(k)); + } + +- if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_DEFFREQ)) < 0) { ++ if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_30Hz)) < 0) { + FatalError("failed to set graphics mode: %d", k); + } + +@@ -100,6 +109,10 @@ + FatalError(stderr, "32-bit video resolution required"); + } + ++ pthread_t thread; ++ ++ pthread_create(&thread, NULL, (void*) refresher, &priv->g); ++ + priv->fb = priv->g.data; + + priv->g.height = priv->g.height; diff --git a/tinyx/patches/tinyx/eed490/10-vga.patch b/tinyx/patches/tinyx/eed490/10-vga.patch new file mode 100644 index 0000000..5ad408b --- /dev/null +++ b/tinyx/patches/tinyx/eed490/10-vga.patch @@ -0,0 +1,78 @@ +diff -ruN a/kdrive/fbdev/fbdev.c b/kdrive/fbdev/fbdev.c +--- a/kdrive/fbdev/fbdev.c 2024-08-21 13:07:32.038968445 +0200 ++++ b/kdrive/fbdev/fbdev.c 2024-08-21 12:26:44.467523732 +0200 +@@ -28,6 +28,15 @@ + #include + + #include ++#include ++ ++void refresher(void *arg) { ++ graph_t* g = (graph_t*) arg; ++ while (1) { ++ usleep(12588); // ~70Hz ++ graph_commit(g); ++ } ++} + + extern int KdTsPhyScreen; + +@@ -80,7 +89,6 @@ + + int k; + +- priv->bits_per_pixel = 32; + priv->smem_len = 0x2000; + + if ((k = graph_init()) < 0) { +@@ -92,15 +100,16 @@ + FatalError("failed to initialize graphics adapter: %s", strerror(k)); + } + +- if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_DEFFREQ)) < 0) { ++ if ((k = graph_mode(&priv->g, GRAPH_DEFMODE, GRAPH_70Hz)) < 0) { + FatalError("failed to set graphics mode: %d", k); + } + +- if (priv->g.depth != 4) { +- FatalError(stderr, "32-bit video resolution required"); +- } ++ pthread_t thread; ++ ++ pthread_create(&thread, NULL, (void*) refresher, &priv->g); + + priv->fb = priv->g.data; ++ priv->bits_per_pixel = priv->g.depth * 8; + + priv->g.height = priv->g.height; + priv->g.width = priv->g.width; +@@ -316,22 +325,22 @@ + FbdevPriv *priv = screen->card->driver; + int depth = priv->bits_per_pixel; + +- screen->width = 640; +- screen->height = 400; ++ screen->width = priv->g.width; ++ screen->height = priv->g.height; + screen->rate = 30; + screen->fb.depth = depth; + +- depth = priv->bits_per_pixel; +- + /* Calculate line_length if it's zero */ + if (!priv->line_length) + priv->line_length = (priv->g.width * depth + 7) / 8; + + screen->fb.visuals = (1 << TrueColor); ++ + #define Mask(o,l) (((1 << l) - 1) << o) +- screen->fb.redMask = Mask(16,8); +- screen->fb.greenMask = Mask(8,8); +- screen->fb.blueMask = Mask(0,8); ++ int offset = depth / 4; ++ screen->fb.redMask = Mask(offset * 2, offset); ++ screen->fb.greenMask = Mask(offset * 1, offset); ++ screen->fb.blueMask = Mask(0,offset); + screen->fb.bitsPerPixel = priv->bits_per_pixel; + + return fbdevMapFramebuffer(screen); diff --git a/tinyx/patches/tinyxlib/9862f3/18-Xtranssock-dontwait.patch b/tinyx/patches/tinyxlib/9862f3/18-Xtranssock-dontwait.patch new file mode 100644 index 0000000..beb52cf --- /dev/null +++ b/tinyx/patches/tinyxlib/9862f3/18-Xtranssock-dontwait.patch @@ -0,0 +1,24 @@ +diff -ruN a/libxtrans/Xtranssock.c b/libxtrans/Xtranssock.c +--- a/libxtrans/Xtranssock.c 2024-08-05 09:04:38.631732705 +0200 ++++ b/libxtrans/Xtranssock.c 2024-08-21 17:11:03.820006544 +0200 +@@ -1547,11 +1547,17 @@ + { + /* this bufsize doesn't really matter, but using recv() as a replacement + * for ioctl/FIONREAD is quite slow +- * TODO implement ioctl/FIONREAD in phoenix kernel */ ++ * Maybe implement ioctl/FIONREAD in phoenix kernel? */ + #define BUFSIZE 64 + static char buf[BUFSIZE]; +- *pend = recv(ciptr->fd, buf, BUFSIZE, MSG_PEEK); +- if (pend < 0) return -1; ++ int k = recv(ciptr->fd, buf, BUFSIZE, MSG_PEEK | MSG_DONTWAIT); ++ if (k < 0) { ++ if (errno == EWOULDBLOCK || errno == EAGAIN) ++ k = 0; ++ else ++ return -1; ++ } ++ *pend = k; + return 0; + } + diff --git a/tinyx/patches/twm/1.0.12/01-twm.patch b/tinyx/patches/twm/1.0.12/01-twm.patch new file mode 100644 index 0000000..1d05eeb --- /dev/null +++ b/tinyx/patches/twm/1.0.12/01-twm.patch @@ -0,0 +1,73 @@ +diff -ruN a/configure.ac b/configure.ac +--- a/configure.ac 2022-04-02 20:36:49.000000000 +0200 ++++ b/configure.ac 2024-08-20 10:45:57.220251974 +0200 +@@ -50,10 +50,6 @@ + + # Checks for pkg-config packages + PKG_CHECK_MODULES([TWM], [x11 xext xt xmu ice sm xproto >= 7.0.17]) +-PKG_CHECK_MODULES([XRANDR], [xrandr], [have_xrandr=yes], [have_xrandr=no]) +-if test "$have_xrandr" = yes; then +- AC_DEFINE([HAVE_XRANDR], [1], [Define to 1 if you have the xrandr headers/libraries]) +-fi + + AC_CONFIG_FILES([Makefile + src/Makefile +diff -ruN a/src/menus.c b/src/menus.c +--- a/src/menus.c 2022-04-02 20:36:49.000000000 +0200 ++++ b/src/menus.c 2024-08-20 10:53:18.394309064 +0200 +@@ -79,7 +79,9 @@ + #include "session.h" + #include + #include "version.h" +-#include ++#include ++#include ++#include + #include + + int RootFunction = 0; +@@ -1906,6 +1908,7 @@ + Bell(XkbBI_MinorError, 0, tmp_win->w); + break; + ++#if 0 + case F_CIRCLEUP: + XCirculateSubwindowsUp(dpy, Scr->Root); + break; +@@ -1913,6 +1916,7 @@ + case F_CIRCLEDOWN: + XCirculateSubwindowsDown(dpy, Scr->Root); + break; ++#endif + + case F_EXEC: + PopDownMenu(); +diff -ruN a/src/parse.c b/src/parse.c +--- a/src/parse.c 2022-04-02 20:36:49.000000000 +0200 ++++ b/src/parse.c 2024-08-20 10:48:18.826964856 +0200 +@@ -69,8 +69,10 @@ + #include "gram.h" + #include "parse.h" + ++#include + #include +-#include ++#include ++#include + + #ifndef SYSTEM_INIT_FILE + #define SYSTEM_INIT_FILE "/usr/lib/X11/twm/system.twmrc" +diff -ruN a/src/twm.c b/src/twm.c +--- a/src/twm.c 2022-04-02 20:36:49.000000000 +0200 ++++ b/src/twm.c 2024-08-20 10:53:07.850111898 +0200 +@@ -81,7 +81,9 @@ + #include + #include + #include +-#include ++#include ++#include ++#include + #include + + #ifdef XPRINT diff --git a/tinyx/patches/xedit/1.2.4/01-xedit.patch b/tinyx/patches/xedit/1.2.4/01-xedit.patch new file mode 100644 index 0000000..103fc93 --- /dev/null +++ b/tinyx/patches/xedit/1.2.4/01-xedit.patch @@ -0,0 +1,96 @@ +diff -ruN a/lisp/core.c b/lisp/core.c +--- a/lisp/core.c 2024-08-19 12:28:56.555383918 +0200 ++++ b/lisp/core.c 2024-08-19 12:31:07.967361118 +0200 +@@ -66,6 +66,10 @@ + # define finite(x) isfinite(x) + #endif + ++#ifdef __phoenix__ ++# define finite(x) 1 ++#endif ++ + #ifdef NEED_SETENV + extern int setenv(const char *name, const char *value, int overwrite); + extern void unsetenv(const char *name); +diff -ruN a/lisp/math.c b/lisp/math.c +--- a/lisp/math.c 2024-08-19 12:28:56.555383918 +0200 ++++ b/lisp/math.c 2024-08-19 12:29:55.835300679 +0200 +@@ -36,6 +36,10 @@ + # define finite(x) isfinite(x) + #endif + ++#ifdef __phoenix__ ++# define finite(x) 1 ++#endif ++ + /* + * Prototypes + */ +diff -ruN a/lisp/mathimp.c b/lisp/mathimp.c +--- a/lisp/mathimp.c 2024-08-19 12:28:56.560383997 +0200 ++++ b/lisp/mathimp.c 2024-08-19 12:30:23.308711307 +0200 +@@ -115,6 +115,10 @@ + #define XALLOC(type) LispMalloc(sizeof(type)) + #define XFREE(ptr) LispFree(ptr) + ++#ifdef __phoenix__ ++# define finite(x) 1 ++#endif ++ + + /* + * Types +diff -ruN a/lisp/mp/mpi.c b/lisp/mp/mpi.c +--- a/lisp/mp/mpi.c 2024-08-19 12:28:56.554383902 +0200 ++++ b/lisp/mp/mpi.c 2024-08-19 12:34:23.239985506 +0200 +@@ -35,6 +35,18 @@ + # define finite(x) isfinite(x) + #endif + ++#ifdef __phoenix__ ++# define finite(x) 1 ++#endif ++ ++double ++copysign (double x, double y) ++{ ++ if ((x < 0 && y > 0) || (x > 0 && y < 0)) ++ return -x; ++ return x; ++} ++ + /* + * Prototypes + */ +diff -ruN a/lisp/read.c b/lisp/read.c +--- a/lisp/read.c 2024-08-19 12:28:56.559383981 +0200 ++++ b/lisp/read.c 2024-08-19 12:30:49.260091486 +0200 +@@ -66,6 +66,10 @@ + # define finite(x) isfinite(x) + #endif + ++#ifdef __phoenix__ ++# define finite(x) 1 ++#endif ++ + /* + * Types + */ +diff -ruN a/lisp/time.c b/lisp/time.c +--- a/lisp/time.c 2024-08-19 15:11:29.217093390 +0200 ++++ b/lisp/time.c 2024-08-19 15:11:55.270484673 +0200 +@@ -41,6 +41,8 @@ + time form + */ + { ++ return NULL; ++#if 0 + struct itimerval real, virt, prof; + unsigned long count; + long sec, usec; +@@ -135,4 +137,5 @@ + lisp__data.gc.timebits = 0; + + return (result); ++#endif + } diff --git a/tinyx/patches/xeyes/1.1.1/01-hypot.patch b/tinyx/patches/xeyes/1.1.1/01-hypot.patch new file mode 100644 index 0000000..e8ac80a --- /dev/null +++ b/tinyx/patches/xeyes/1.1.1/01-hypot.patch @@ -0,0 +1,11 @@ +diff -ruN a/Eyes.c b/Eyes.c +--- a/Eyes.c 2024-08-19 11:59:47.698361121 +0200 ++++ b/Eyes.c 2024-08-19 12:00:01.299368023 +0200 +@@ -55,6 +55,7 @@ + + #define offset(field) XtOffsetOf(EyesRec, eyes.field) + #define goffset(field) XtOffsetOf(WidgetRec, core.field) ++#define hypot(x,y) sqrt(((x)*(x))+((y)*(y))) + + static XtResource resources[] = { + {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension),