From c821a73ed4b6c9e139a3e0513031e2c6f6e540bf Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Fri, 20 Feb 2026 15:52:29 -0800 Subject: [PATCH 01/19] Updates build environment to Ubuntu Linux 24.04 --- .github/workflows/Dockerfile_builder | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Dockerfile_builder b/.github/workflows/Dockerfile_builder index 5988ce1..cb6c48f 100755 --- a/.github/workflows/Dockerfile_builder +++ b/.github/workflows/Dockerfile_builder @@ -8,11 +8,11 @@ # # ****************************************************************************** -FROM ubuntu:22.04 +FROM ubuntu:24.04 SHELL ["/bin/bash", "-c"] USER root:root # Install build tools -RUN apt-get update && apt-get install -y make clang libx11-dev gcc +RUN apt-get update && apt-get install -y make clang libx11-dev libbsd-dev libpcap-dev gcc USER root WORKDIR /root ENTRYPOINT /bin/bash From 97b84d4117fc082cfd91e2b13a8def0fdb6acca6 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Sun, 1 Mar 2026 03:00:08 -0800 Subject: [PATCH 02/19] Add libbsd to ld library search for all makefile-linux* and makefile-init-linux*. Add libbsd to MAIKO_LIBRARIES (where appropriate) in CMakeLists.txt. This will support building maiko on Ubuntu 22.04 and Debian 12, where strlcat is found only in libbsd. For Ubuntu 24.04 and beyond and Debian 13 and beyond, strlcat is now in glibc (>2.38). --- CMakeLists.txt | 7 ++++++- bin/makefile-init-linux.aarch64 | 4 ++-- bin/makefile-init-linux.x86_64 | 4 ++-- bin/makefile-init-wsl1.aarch64 | 4 ++-- bin/makefile-init-wsl1.x86_64 | 4 ++-- bin/makefile-linux.386-sdl | 4 ++-- bin/makefile-linux.386-x | 4 ++-- bin/makefile-linux.aarch64-sdl | 4 ++-- bin/makefile-linux.aarch64-x | 4 ++-- bin/makefile-linux.armv7l-sdl | 4 ++-- bin/makefile-linux.armv7l-x | 4 ++-- bin/makefile-linux.x86_64-sdl | 4 ++-- bin/makefile-linux.x86_64-x | 4 ++-- bin/makefile-wsl1.aarch64-sdl | 4 ++-- bin/makefile-wsl1.aarch64-x | 4 ++-- bin/makefile-wsl1.x86_64-sdl | 4 ++-- bin/makefile-wsl1.x86_64-x | 4 ++-- 17 files changed, 38 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index eb1f811..8c747c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.15) PROJECT(maiko C) - SET(CMAKE_EXPORT_COMPILE_COMMANDS ON) SET(CMAKE_C_STANDARD 99) @@ -37,6 +36,11 @@ IF(NEED_LIB_M) SET(MAIKO_LIBRARIES m) ENDIF() +CHECK_LIBRARY_EXISTS(bsd strlcat "" NEED_LIB_BSD) +IF(NEED_LIB_BSD) + SET(MAIKO_LIBRARIES ${MAIKO_LIBRARIES} bsd) +ENDIF() + SET (MAIKO_RELEASE 351 CACHE STRING "Release version to build. Release: 115, 200, 201, 210, 300, 350, 351") SET_PROPERTY(CACHE MAIKO_RELEASE PROPERTY STRINGS 115 200 201 210 300 350 351) @@ -448,6 +452,7 @@ ADD_CUSTOM_COMMAND(OUTPUT vdate.c ADD_EXECUTABLE(lde src/ldeboot.c src/unixfork.c) TARGET_COMPILE_DEFINITIONS(lde PRIVATE ${MAIKO_DEFINITIONS}) TARGET_INCLUDE_DIRECTORIES(lde PRIVATE inc) +TARGET_LINK_LIBRARIES(lde ${MAIKO_LIBRARIES}) IF(MAIKO_DISPLAY_X11) # Tell it that the X11 launcher is available. TARGET_COMPILE_DEFINITIONS(lde PRIVATE ${MAIKO_DISPLAY_X11_DEFINITIONS}) diff --git a/bin/makefile-init-linux.aarch64 b/bin/makefile-init-linux.aarch64 index 52ab52b..5b4ce1d 100644 --- a/bin/makefile-init-linux.aarch64 +++ b/bin/makefile-init-linux.aarch64 @@ -21,8 +21,8 @@ OPTFLAGS = -O0 -g DEBUGFLAGS = DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-init-linux.x86_64 b/bin/makefile-init-linux.x86_64 index 8eeb208..ae6e2cf 100644 --- a/bin/makefile-init-linux.x86_64 +++ b/bin/makefile-init-linux.x86_64 @@ -21,8 +21,8 @@ OPTFLAGS = -O0 -g DEBUGFLAGS = DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-init-wsl1.aarch64 b/bin/makefile-init-wsl1.aarch64 index 5362d82..7fb5fce 100644 --- a/bin/makefile-init-wsl1.aarch64 +++ b/bin/makefile-init-wsl1.aarch64 @@ -21,8 +21,8 @@ OPTFLAGS = -O0 -g DEBUGFLAGS = DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT -D__wsl1__ -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-init-wsl1.x86_64 b/bin/makefile-init-wsl1.x86_64 index 182631f..a35a195 100644 --- a/bin/makefile-init-wsl1.x86_64 +++ b/bin/makefile-init-wsl1.x86_64 @@ -21,8 +21,8 @@ OPTFLAGS = -O0 -g DEBUGFLAGS = DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT -D__wsl1__ -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.386-sdl b/bin/makefile-linux.386-sdl index 733f3c7..40f2706 100644 --- a/bin/makefile-linux.386-sdl +++ b/bin/makefile-linux.386-sdl @@ -17,8 +17,8 @@ XFLAGS = -DSDL=2 OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -LDFLAGS = -lm -lSDL2 -LDELDFLAGS = +LDFLAGS = -lm -lSDL2 -lbsd +LDELDFLAGS = -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.386-x b/bin/makefile-linux.386-x index e733b9a..62c0bc4 100644 --- a/bin/makefile-linux.386-x +++ b/bin/makefile-linux.386-x @@ -19,8 +19,8 @@ XFLAGS = -DXWINDOW OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.aarch64-sdl b/bin/makefile-linux.aarch64-sdl index 94b719c..6d450be 100644 --- a/bin/makefile-linux.aarch64-sdl +++ b/bin/makefile-linux.aarch64-sdl @@ -17,8 +17,8 @@ SDLFLAGS = -DSDL=2 OPTFLAGS = -O2 -g3 DFLAGS = $(SDLFLAGS) -DRELEASE=$(RELEASE) -LDFLAGS = -lSDL2 -lm -LDELDFLAGS = +LDFLAGS = -lSDL2 -lm -lbsd +LDELDFLAGS = -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.aarch64-x b/bin/makefile-linux.aarch64-x index ff0b349..a001209 100644 --- a/bin/makefile-linux.aarch64-x +++ b/bin/makefile-linux.aarch64-x @@ -19,8 +19,8 @@ XFLAGS = -DXWINDOW OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.armv7l-sdl b/bin/makefile-linux.armv7l-sdl index da9c4cc..86e4f47 100644 --- a/bin/makefile-linux.armv7l-sdl +++ b/bin/makefile-linux.armv7l-sdl @@ -17,8 +17,8 @@ XFLAGS = -DSDL=2 OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -LDFLAGS = -lm -lSDL2 -LDELDFLAGS = +LDFLAGS = -lm -lSDL2 -lbsd +LDELDFLAGS = -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.armv7l-x b/bin/makefile-linux.armv7l-x index ee283b4..1e3740c 100644 --- a/bin/makefile-linux.armv7l-x +++ b/bin/makefile-linux.armv7l-x @@ -19,8 +19,8 @@ XFLAGS = -DXWINDOW OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.x86_64-sdl b/bin/makefile-linux.x86_64-sdl index ccf98c3..c57dca0 100644 --- a/bin/makefile-linux.x86_64-sdl +++ b/bin/makefile-linux.x86_64-sdl @@ -17,8 +17,8 @@ XFLAGS = -DSDL=2 OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -LDFLAGS = -lm -lSDL2 -LDELDFLAGS = +LDFLAGS = -lm -lSDL2 -lbsd +LDELDFLAGS = -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.x86_64-x b/bin/makefile-linux.x86_64-x index e9225aa..5cb63bb 100644 --- a/bin/makefile-linux.x86_64-x +++ b/bin/makefile-linux.x86_64-x @@ -20,8 +20,8 @@ XFLAGS = -DXWINDOW OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-wsl1.aarch64-sdl b/bin/makefile-wsl1.aarch64-sdl index f3ce3ca..7e756e9 100644 --- a/bin/makefile-wsl1.aarch64-sdl +++ b/bin/makefile-wsl1.aarch64-sdl @@ -17,8 +17,8 @@ SDLFLAGS = -DSDL=2 OPTFLAGS = -O2 -g3 DFLAGS = $(SDLFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ -LDFLAGS = -lSDL2 -lm -LDELDFLAGS = +LDFLAGS = -lSDL2 -lm -lbsd +LDELDFLAGS = -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-wsl1.aarch64-x b/bin/makefile-wsl1.aarch64-x index 15964b5..fb57847 100644 --- a/bin/makefile-wsl1.aarch64-x +++ b/bin/makefile-wsl1.aarch64-x @@ -19,8 +19,8 @@ XFLAGS = -DXWINDOW OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-wsl1.x86_64-sdl b/bin/makefile-wsl1.x86_64-sdl index ec16b95..5bad16a 100644 --- a/bin/makefile-wsl1.x86_64-sdl +++ b/bin/makefile-wsl1.x86_64-sdl @@ -17,8 +17,8 @@ XFLAGS = -DSDL=2 OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ -LDFLAGS = -lm -lSDL2 -LDELDFLAGS = +LDFLAGS = -lm -lSDL2 -lbsd +LDELDFLAGS = -lbsd OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-wsl1.x86_64-x b/bin/makefile-wsl1.x86_64-x index fe1b6c0..6c12433 100644 --- a/bin/makefile-wsl1.x86_64-x +++ b/bin/makefile-wsl1.x86_64-x @@ -20,8 +20,8 @@ XFLAGS = -DXWINDOW OPTFLAGS = -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd OBJECTDIR = ../$(RELEASENAME)/ From f4021ef26824c0dd73ecb9e3ab29075110a1fac8 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Sun, 1 Mar 2026 03:21:04 -0800 Subject: [PATCH 03/19] Move builder image back to 22.04 so that exe's that we build can run on systems with glibc <2.38 (e.g., Ubuntu 22.04 and Debian 12). --- .github/workflows/Dockerfile_builder | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Dockerfile_builder b/.github/workflows/Dockerfile_builder index cb6c48f..87ff0a5 100755 --- a/.github/workflows/Dockerfile_builder +++ b/.github/workflows/Dockerfile_builder @@ -8,7 +8,7 @@ # # ****************************************************************************** -FROM ubuntu:24.04 +FROM ubuntu:22.04 SHELL ["/bin/bash", "-c"] USER root:root # Install build tools From fcbcb2c6b82f65c2acd8743cd99faa9169457a52 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Mon, 9 Mar 2026 00:45:09 -0700 Subject: [PATCH 04/19] Updating all linux makefiles to use the libbsd-overlay scheme properly --- bin/makefile-init-linux.aarch64 | 10 +++++++--- bin/makefile-init-linux.x86_64 | 10 +++++++--- bin/makefile-linux-check-prerequisites | 20 ++++++++++++++++++++ bin/makefile-linux.386-sdl | 10 +++++++--- bin/makefile-linux.386-x | 10 +++++++--- bin/makefile-linux.aarch64-sdl | 10 +++++++--- bin/makefile-linux.aarch64-x | 10 +++++++--- bin/makefile-linux.armv7l-sdl | 10 +++++++--- bin/makefile-linux.armv7l-x | 10 +++++++--- bin/makefile-linux.x86_64-sdl | 10 +++++++--- bin/makefile-linux.x86_64-x | 10 +++++++--- 11 files changed, 90 insertions(+), 30 deletions(-) create mode 100644 bin/makefile-linux-check-prerequisites diff --git a/bin/makefile-init-linux.aarch64 b/bin/makefile-init-linux.aarch64 index 5b4ce1d..5ba7fd2 100644 --- a/bin/makefile-init-linux.aarch64 +++ b/bin/makefile-init-linux.aarch64 @@ -16,13 +16,17 @@ XFILES = $(OBJECTDIR)xmkicon.o \ XFLAGS = -DXWINDOW +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it OPTFLAGS = -O0 -g DEBUGFLAGS = -DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT +DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT $(BSD_CFLAGS) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-init-linux.x86_64 b/bin/makefile-init-linux.x86_64 index ae6e2cf..14f142e 100644 --- a/bin/makefile-init-linux.x86_64 +++ b/bin/makefile-init-linux.x86_64 @@ -16,13 +16,17 @@ XFILES = $(OBJECTDIR)xmkicon.o \ XFLAGS = -DXWINDOW +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it OPTFLAGS = -O0 -g DEBUGFLAGS = -DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT +DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT $(BSD_CFLAGS) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux-check-prerequisites b/bin/makefile-linux-check-prerequisites new file mode 100644 index 0000000..352fc55 --- /dev/null +++ b/bin/makefile-linux-check-prerequisites @@ -0,0 +1,20 @@ +# Check that pkg-config is available and that the libbsd-dev package is installed +# If one of these is missing, error out +# FGH 2026-03-08 +ifneq ($(MAKECMDGOALS),clean) + ifneq ($(MAKECMDGOALS),cleanup) + + CHK_PKG_CONFIG := $(shell command -v pkg-config) + ifeq ($(CHK_PKG_CONFIG),) + # pkg-config not found, print an error + $(error "pkg-config not found. Please install it to build this project.") + endif + + CHK_LIBBSD_DEV := $(shell pkg-config --exists libbsd-overlay && echo true) + ifneq ($(CHK_LIBBSD_DEV),true) + $(error "libbsd-dev (or libbsd-devel) package not found. Please install it to build this project.") + endif + endif +endif + + diff --git a/bin/makefile-linux.386-sdl b/bin/makefile-linux.386-sdl index 40f2706..f47ea44 100644 --- a/bin/makefile-linux.386-sdl +++ b/bin/makefile-linux.386-sdl @@ -13,12 +13,16 @@ XFILES = $(OBJECTDIR)sdl.o # XFLAGS = -DSDL=2 +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) -LDFLAGS = -lm -lSDL2 -lbsd -LDELDFLAGS = -lbsd +LDFLAGS = -lm -lSDL2 $(BSD_LDFLAGS) +LDELDFLAGS = $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.386-x b/bin/makefile-linux.386-x index 62c0bc4..8c97572 100644 --- a/bin/makefile-linux.386-x +++ b/bin/makefile-linux.386-x @@ -15,12 +15,16 @@ XFILES = $(OBJECTDIR)xmkicon.o \ XFLAGS = -DXWINDOW +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.aarch64-sdl b/bin/makefile-linux.aarch64-sdl index 6d450be..2559f21 100644 --- a/bin/makefile-linux.aarch64-sdl +++ b/bin/makefile-linux.aarch64-sdl @@ -13,12 +13,16 @@ XFILES = $(OBJECTDIR)sdl.o # SDLFLAGS = -DSDL=2 +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 -DFLAGS = $(SDLFLAGS) -DRELEASE=$(RELEASE) +DFLAGS = $(SDLFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) -LDFLAGS = -lSDL2 -lm -lbsd -LDELDFLAGS = -lbsd +LDFLAGS = -lSDL2 -lm $(BSD_LDFLAGS) +LDELDFLAGS = $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.aarch64-x b/bin/makefile-linux.aarch64-x index a001209..99a58ca 100644 --- a/bin/makefile-linux.aarch64-x +++ b/bin/makefile-linux.aarch64-x @@ -15,12 +15,16 @@ XFILES = $(OBJECTDIR)xmkicon.o \ XFLAGS = -DXWINDOW +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.armv7l-sdl b/bin/makefile-linux.armv7l-sdl index 86e4f47..47a87a6 100644 --- a/bin/makefile-linux.armv7l-sdl +++ b/bin/makefile-linux.armv7l-sdl @@ -13,12 +13,16 @@ XFILES = $(OBJECTDIR)sdl.o # XFLAGS = -DSDL=2 +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) -LDFLAGS = -lm -lSDL2 -lbsd -LDELDFLAGS = -lbsd +LDFLAGS = -lm -lSDL2 $(BSD_LDFLAGS) +LDELDFLAGS = $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.armv7l-x b/bin/makefile-linux.armv7l-x index 1e3740c..fa787fb 100644 --- a/bin/makefile-linux.armv7l-x +++ b/bin/makefile-linux.armv7l-x @@ -15,12 +15,16 @@ XFILES = $(OBJECTDIR)xmkicon.o \ XFLAGS = -DXWINDOW +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.x86_64-sdl b/bin/makefile-linux.x86_64-sdl index c57dca0..640a59c 100644 --- a/bin/makefile-linux.x86_64-sdl +++ b/bin/makefile-linux.x86_64-sdl @@ -13,12 +13,16 @@ XFILES = $(OBJECTDIR)sdl.o # XFLAGS = -DSDL=2 +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) -LDFLAGS = -lm -lSDL2 -lbsd -LDELDFLAGS = -lbsd +LDFLAGS = -lm -lSDL2 $(BSD_LDFLAGS) +LDELDFLAGS = $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux.x86_64-x b/bin/makefile-linux.x86_64-x index 5cb63bb..87016b4 100644 --- a/bin/makefile-linux.x86_64-x +++ b/bin/makefile-linux.x86_64-x @@ -16,12 +16,16 @@ XFILES = $(OBJECTDIR)xmkicon.o \ XFLAGS = -DXWINDOW +include makefile-linux-check-prerequisites +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + # OPTFLAGS is normally -O2. OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd +LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) +LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ From 41cad3e499084306a65a54935704a4ac3c15bb4f Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Mon, 9 Mar 2026 18:11:23 -0700 Subject: [PATCH 05/19] Update all makefiles for linux to use (by include) a common base makefile as well as common makefiles for X and sdl. These included makefiles have the name linux-*.mk. Updated all linux makefiles to use the libbsd-overlay package, using pkg-config to set the appropriate flags. Updated CMakelists to also use the libbsd-overlay package via pkgconfig for Linux only. Finally added install targets to the CMakelists file so that cmake --install . will place the lde binaries into the appropriate directory in maiko as the makefiles currently do. --- CMakeLists.txt | 25 ++++++++++++++-- bin/linux-common.mk | 15 ++++++++++ ...ux-check-prerequisites => linux-libbsd.mk} | 4 +++ bin/linux-sdl.mk | 14 +++++++++ bin/linux-x.mk | 17 +++++++++++ bin/makefile-init-linux.aarch64 | 29 +++--------------- bin/makefile-init-linux.x86_64 | 29 +++--------------- bin/makefile-linux.386-sdl | 27 +++-------------- bin/makefile-linux.386-x | 29 +++--------------- bin/makefile-linux.aarch64-sdl | 26 ++-------------- bin/makefile-linux.aarch64-x | 28 ++--------------- bin/makefile-linux.armv7l-sdl | 26 ++-------------- bin/makefile-linux.armv7l-x | 28 ++--------------- bin/makefile-linux.x86_64-sdl | 27 +++-------------- bin/makefile-linux.x86_64-x | 30 +++---------------- 15 files changed, 104 insertions(+), 250 deletions(-) create mode 100644 bin/linux-common.mk rename bin/{makefile-linux-check-prerequisites => linux-libbsd.mk} (85%) create mode 100644 bin/linux-sdl.mk create mode 100644 bin/linux-x.mk diff --git a/CMakeLists.txt b/CMakeLists.txt index 8c747c3..a1842d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,9 +36,10 @@ IF(NEED_LIB_M) SET(MAIKO_LIBRARIES m) ENDIF() -CHECK_LIBRARY_EXISTS(bsd strlcat "" NEED_LIB_BSD) -IF(NEED_LIB_BSD) - SET(MAIKO_LIBRARIES ${MAIKO_LIBRARIES} bsd) +IF (CMAKE_SYSTEM_NAME STREQUAL "Linux") + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBBSD-OVERLAY REQUIRED IMPORTED_TARGET "libbsd-overlay") + SET(MAIKO_LIBRARIES ${MAIKO_LIBRARIES} PkgConfig::LIBBSD-OVERLAY) ENDIF() SET (MAIKO_RELEASE 351 CACHE STRING "Release version to build. Release: 115, 200, 201, 210, 300, 350, 351") @@ -533,3 +534,21 @@ TARGET_INCLUDE_DIRECTORIES(setsout PRIVATE inc) ADD_EXECUTABLE(tstsout src/tstsout.c src/byteswap.c) TARGET_COMPILE_DEFINITIONS(tstsout PRIVATE ${MAIKO_DEFINITIONS}) TARGET_INCLUDE_DIRECTORIES(tstsout PRIVATE inc) + +# Installation Targets +IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/../" CACHE PATH "Installation prefix" FORCE) +ENDIF() +execute_process( + COMMAND sh -c "echo $(../bin/osversion).$(../bin/machinetype)" + OUTPUT_VARIABLE release_dir + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE +) +INSTALL(TARGETS lde DESTINATION ${release_dir}) +IF(MAIKO_DISPLAY_X11) + INSTALL(TARGETS ldex ldeinit DESTINATION ${release_dir}) +ENDIF() +IF(MAIKO_DISPLAY_SDL) + INSTALL(TARGETS ldesdl DESTINATION ${release_dir}) +ENDIF() diff --git a/bin/linux-common.mk b/bin/linux-common.mk new file mode 100644 index 0000000..c39251e --- /dev/null +++ b/bin/linux-common.mk @@ -0,0 +1,15 @@ +# Common Options for All Linuxes + +CC = gcc $(GCC_CFLAGS) +# CC = clang $(CLANG_CFLAGS) + +include linux-libbsd.mk + +# OPTFLAGS is normally -O2. +OPTFLAGS = -O2 -g3 +DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) $(ADDITIONAL_DFLAGS) + +LDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) +LDELDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) + +OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/makefile-linux-check-prerequisites b/bin/linux-libbsd.mk similarity index 85% rename from bin/makefile-linux-check-prerequisites rename to bin/linux-libbsd.mk index 352fc55..733a9f4 100644 --- a/bin/makefile-linux-check-prerequisites +++ b/bin/linux-libbsd.mk @@ -17,4 +17,8 @@ ifneq ($(MAKECMDGOALS),clean) endif endif +BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) + +BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) + diff --git a/bin/linux-sdl.mk b/bin/linux-sdl.mk new file mode 100644 index 0000000..764d2fa --- /dev/null +++ b/bin/linux-sdl.mk @@ -0,0 +1,14 @@ +# Common Options for Linux using SDL instead of X Windows + +XFILES = $(OBJECTDIR)sdl.o + +# +# For SDL version 2 +# -DSDL=2 in XFLAGS and -lSDL2 in LDFLAGS +# For SDL version 3 +# -DSDL=3 in XFLAGS and -lSDL3 in LDFLAGS +# +XFLAGS = -DSDL=2 + +XLDFLAGS = -lSDL2 + diff --git a/bin/linux-x.mk b/bin/linux-x.mk new file mode 100644 index 0000000..730eea1 --- /dev/null +++ b/bin/linux-x.mk @@ -0,0 +1,17 @@ +# Common Options for Linux with X Windows + +XFILES = $(OBJECTDIR)xmkicon.o \ + $(OBJECTDIR)xbbt.o \ + $(OBJECTDIR)dspif.o \ + $(OBJECTDIR)xinit.o \ + $(OBJECTDIR)xscroll.o \ + $(OBJECTDIR)xcursor.o \ + $(OBJECTDIR)xlspwin.o \ + $(OBJECTDIR)xrdopt.o \ + $(OBJECTDIR)xwinman.o + + +XFLAGS = -DXWINDOW + +XLDFLAGS = -L/usr/X11/lib -lX11 + diff --git a/bin/makefile-init-linux.aarch64 b/bin/makefile-init-linux.aarch64 index 5ba7fd2..3920d46 100644 --- a/bin/makefile-init-linux.aarch64 +++ b/bin/makefile-init-linux.aarch64 @@ -1,33 +1,12 @@ # Options for Linux, aarch64 processor, X windows, for INIT processing -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) +include linux-x.mk -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o - - -XFLAGS = -DXWINDOW - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it -OPTFLAGS = -O0 -g DEBUGFLAGS = -DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT $(BSD_CFLAGS) +ADDITIONAL_DFLAGS = $(DEBUGFLAGS) -DNOVERSION -DINIT -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) +include linux-common.mk -OBJECTDIR = ../$(RELEASENAME)/ +OPTFLAGS = -O0 -g default : ../$(OSARCHNAME)/ldeinit diff --git a/bin/makefile-init-linux.x86_64 b/bin/makefile-init-linux.x86_64 index 14f142e..eb33754 100644 --- a/bin/makefile-init-linux.x86_64 +++ b/bin/makefile-init-linux.x86_64 @@ -1,33 +1,12 @@ # Options for Linux, x86 processor, X windows, for INIT processing -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) +include linux-x.mk -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o - - -XFLAGS = -DXWINDOW - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it -OPTFLAGS = -O0 -g DEBUGFLAGS = -DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT $(BSD_CFLAGS) +ADDITIONAL_DFLAGS = $(DEBUGFLAGS) -DNOVERSION -DINIT -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) +include linux-common.mk -OBJECTDIR = ../$(RELEASENAME)/ +OPTFLAGS = -O0 -g default : ../$(OSARCHNAME)/ldeinit diff --git a/bin/makefile-linux.386-sdl b/bin/makefile-linux.386-sdl index f47ea44..28b61fe 100644 --- a/bin/makefile-linux.386-sdl +++ b/bin/makefile-linux.386-sdl @@ -1,29 +1,10 @@ # Options for Linux, Intel 386/486 and SDL -CC = gcc -m32 $(GCC_CFLAGS) -# CC = clang $(CLANG_CFLAGS) +GCC_CFLAGS := -m64 $(GCC_CFLAGS) +CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) -XFILES = $(OBJECTDIR)sdl.o +include linux-sdl.mk -# -# For SDL version 2 -# -DSDL=2 in XFLAGS and -lSDL2 in LDFLAGS -# For SDL version 3 -# -DSDL=3 in XFLAGS and -lSDL3 in LDFLAGS -# -XFLAGS = -DSDL=2 - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) - -LDFLAGS = -lm -lSDL2 $(BSD_LDFLAGS) -LDELDFLAGS = $(BSD_LDFLAGS) - -OBJECTDIR = ../$(RELEASENAME)/ +include linux-common.mk default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl diff --git a/bin/makefile-linux.386-x b/bin/makefile-linux.386-x index 8c97572..3ce00c4 100644 --- a/bin/makefile-linux.386-x +++ b/bin/makefile-linux.386-x @@ -1,31 +1,10 @@ # Options for Linux, Intel 386/486 and X-Window -CC = gcc -m32 $(GCC_CFLAGS) -# CC = clang -m32 $(CLANG_CFLAGS) +GCC_CFLAGS := -m32 $(GCC_CFLAGS) +CLANG_CFLAGS := -m32 $(CLANG_CFLAGS) -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o +include linux-x.mk -XFLAGS = -DXWINDOW - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) - -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) - -OBJECTDIR = ../$(RELEASENAME)/ +include linux-common.mk default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex diff --git a/bin/makefile-linux.aarch64-sdl b/bin/makefile-linux.aarch64-sdl index 2559f21..dcf5c1d 100644 --- a/bin/makefile-linux.aarch64-sdl +++ b/bin/makefile-linux.aarch64-sdl @@ -1,29 +1,7 @@ # Options for Linux, ARM64 and SDL -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) +include linux-sdl.mk -XFILES = $(OBJECTDIR)sdl.o - -# -# For SDL version 2 -# -DSDL=2 in SDLFLAGS and -lSDL2 in LDFLAGS -# For SDL version 3 -# -DSDL=3 in SDLFLAGS and -lSDL3 in LDFLAGS -# -SDLFLAGS = -DSDL=2 - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(SDLFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) - -LDFLAGS = -lSDL2 -lm $(BSD_LDFLAGS) -LDELDFLAGS = $(BSD_LDFLAGS) - -OBJECTDIR = ../$(RELEASENAME)/ +include linux-common.mk default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl diff --git a/bin/makefile-linux.aarch64-x b/bin/makefile-linux.aarch64-x index 99a58ca..90ecd86 100644 --- a/bin/makefile-linux.aarch64-x +++ b/bin/makefile-linux.aarch64-x @@ -1,31 +1,7 @@ # Options for Linux, aarch64 and X-Window -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) +include linux-x.mk -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o - -XFLAGS = -DXWINDOW - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) - -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) - -OBJECTDIR = ../$(RELEASENAME)/ +include linux-common.mk default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex diff --git a/bin/makefile-linux.armv7l-sdl b/bin/makefile-linux.armv7l-sdl index 47a87a6..5d5f53a 100644 --- a/bin/makefile-linux.armv7l-sdl +++ b/bin/makefile-linux.armv7l-sdl @@ -1,29 +1,7 @@ # Options for Linux, ARMv7 and SDL -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) +include linux-sdl.mk -XFILES = $(OBJECTDIR)sdl.o - -# -# For SDL version 2 -# -DSDL=2 in XFLAGS and -lSDL2 in LDFLAGS -# For SDL version 3 -# -DSDL=3 in XFLAGS and -lSDL3 in LDFLAGS -# -XFLAGS = -DSDL=2 - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) - -LDFLAGS = -lm -lSDL2 $(BSD_LDFLAGS) -LDELDFLAGS = $(BSD_LDFLAGS) - -OBJECTDIR = ../$(RELEASENAME)/ +include linux-common.mk default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl diff --git a/bin/makefile-linux.armv7l-x b/bin/makefile-linux.armv7l-x index fa787fb..b113143 100644 --- a/bin/makefile-linux.armv7l-x +++ b/bin/makefile-linux.armv7l-x @@ -1,31 +1,7 @@ # Options for Linux, ARMv7 and X-Window -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) +include linux-x.mk -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o - -XFLAGS = -DXWINDOW - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) - -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) - -OBJECTDIR = ../$(RELEASENAME)/ +include linux-common.mk default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex diff --git a/bin/makefile-linux.x86_64-sdl b/bin/makefile-linux.x86_64-sdl index 640a59c..47698cb 100644 --- a/bin/makefile-linux.x86_64-sdl +++ b/bin/makefile-linux.x86_64-sdl @@ -1,29 +1,10 @@ # Options for Linux, Intel x86_64 and SDL -CC = gcc -m64 $(GCC_CFLAGS) -# CC = clang -m64 $(CLANG_CFLAGS) +GCC_CFLAGS := -m64 $(GCC_CFLAGS) +CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) -XFILES = $(OBJECTDIR)sdl.o +include linux-sdl.mk -# -# For SDL version 2 -# -DSDL=2 in XFLAGS and -lSDL2 in LDFLAGS -# For SDL version 3 -# -DSDL=3 in XFLAGS and -lSDL3 in LDFLAGS -# -XFLAGS = -DSDL=2 - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) - -LDFLAGS = -lm -lSDL2 $(BSD_LDFLAGS) -LDELDFLAGS = $(BSD_LDFLAGS) - -OBJECTDIR = ../$(RELEASENAME)/ +include linux-common.mk default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl diff --git a/bin/makefile-linux.x86_64-x b/bin/makefile-linux.x86_64-x index 87016b4..6c9f398 100644 --- a/bin/makefile-linux.x86_64-x +++ b/bin/makefile-linux.x86_64-x @@ -1,32 +1,10 @@ # Options for Linux, Intel x86_64 and X-Window -CC = gcc -m64 $(GCC_CFLAGS) -# CC = clang -m64 $(CLANG_CFLAGS) +GCC_CFLAGS := -m64 $(GCC_CFLAGS) +CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o +include linux-x.mk - -XFLAGS = -DXWINDOW - -include makefile-linux-check-prerequisites -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) - -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm $(BSD_LDFLAGS) - -OBJECTDIR = ../$(RELEASENAME)/ +include linux-common.mk default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex From dadbef47bf1aca2d359bb26c44f52b6f5db833d0 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Mon, 9 Mar 2026 20:43:02 -0700 Subject: [PATCH 06/19] Add pkgconf package to things loaded into the Builder Docker image to be used by libbsd changes to linux makefiles --- .github/workflows/Dockerfile_builder | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Dockerfile_builder b/.github/workflows/Dockerfile_builder index 87ff0a5..8a9fc07 100755 --- a/.github/workflows/Dockerfile_builder +++ b/.github/workflows/Dockerfile_builder @@ -12,7 +12,9 @@ FROM ubuntu:22.04 SHELL ["/bin/bash", "-c"] USER root:root # Install build tools -RUN apt-get update && apt-get install -y make clang libx11-dev libbsd-dev libpcap-dev gcc +RUN apt-get update \ + && apt-get install -y build-essential gcc pkgconf make clang cmake \ + && apt-get install -y libx11-dev libbsd-dev libpcap-dev USER root WORKDIR /root ENTRYPOINT /bin/bash From 25654fa09069c18384746e555474d28451d04d19 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Fri, 13 Mar 2026 23:51:50 -0700 Subject: [PATCH 07/19] For Linux makefiles, automated selection of gcc versus clang compiler depending on whats installed. Refactored Linux makefiles to simplify top level makefiles with slightly more complicated common makefiles. Makefiles for Cygwin and WSL1 all rewritten to use the common linux makefiles code. --- bin/linux-common.mk | 28 ++++++++++++++++++----- bin/linux-compiler.mk | 40 +++++++++++++++++++++++++++++++++ bin/linux-sdl.mk | 2 +- bin/makefile-cygwin.x86_64-sdl | 29 +++++------------------- bin/makefile-cygwin.x86_64-x | 31 +++++-------------------- bin/makefile-init-linux.aarch64 | 9 +++----- bin/makefile-init-linux.x86_64 | 9 +++----- bin/makefile-init-wsl1.aarch64 | 28 ++++------------------- bin/makefile-init-wsl1.x86_64 | 28 ++++------------------- bin/makefile-linux.386-sdl | 6 ++--- bin/makefile-linux.386-x | 6 ++--- bin/makefile-linux.aarch64-sdl | 5 ++--- bin/makefile-linux.aarch64-x | 5 ++--- bin/makefile-linux.armv7l-sdl | 5 ++--- bin/makefile-linux.armv7l-x | 5 ++--- bin/makefile-linux.x86_64-sdl | 6 ++--- bin/makefile-linux.x86_64-x | 5 ++--- bin/makefile-wsl1.aarch64-sdl | 26 ++++----------------- bin/makefile-wsl1.aarch64-x | 28 ++++------------------- bin/makefile-wsl1.x86_64-sdl | 28 +++++------------------ bin/makefile-wsl1.x86_64-x | 31 +++++-------------------- 21 files changed, 126 insertions(+), 234 deletions(-) create mode 100644 bin/linux-compiler.mk diff --git a/bin/linux-common.mk b/bin/linux-common.mk index c39251e..7129f74 100644 --- a/bin/linux-common.mk +++ b/bin/linux-common.mk @@ -1,15 +1,33 @@ # Common Options for All Linuxes -CC = gcc $(GCC_CFLAGS) -# CC = clang $(CLANG_CFLAGS) +include linux-compiler.mk -include linux-libbsd.mk +ifeq ($(USE_LIBBSD),T) + include linux-libbsd.mk +else + BSD_CFLAGS := + BSD_LDFLAGS := +endif -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 +ifeq ($(USE_DISPLAY),x) + include linux-x.mk + DEFAULT_TARGET := ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex +endif +ifeq ($(USE_DISPLAY),sdl) + include linux-sdl.mk + DEFAULT_TARGET := ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl +endif +ifeq ($(USE_DISPLAY),init) + include linux-x.mk + DEFAULT_TARGET := ../$(OSARCHNAME)/ldeinit +endif + +OPTFLAGS ?= -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) $(ADDITIONAL_DFLAGS) LDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) LDELDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) OBJECTDIR = ../$(RELEASENAME)/ + +default: $(DEFAULT_TARGET) diff --git a/bin/linux-compiler.mk b/bin/linux-compiler.mk new file mode 100644 index 0000000..e147e8a --- /dev/null +++ b/bin/linux-compiler.mk @@ -0,0 +1,40 @@ +# Select whether to use clang or gcc +# Priority +# 1. If -DUSE_GCC or -DUSE_CLANG on command line (but not both) use the requested compiler. +# 2. If one compiler is installed but not the other, use the installed compiler. +# 3. Use clang + +EXISTS_GCC := $(shell command -v gcc) +EXISTS_CLANG := $(shell command -v clang) +ifeq ($(or $(EXISTS_GCC),$(EXISTS_CLANG)),) + $(error "Cannot find compiler: neither gcc nor clang. Exiting.") +endif +ifneq ($(and $(USE_CLANG),$(USE_GCC)),) + $(error "Cannot use both USE_CLANG=T and USE_GCC=T. Exiting.") +endif +COMPILER := +ifdef USE_CLANG + ifeq ($(EXISTS_CLANG),) + $(error "USE_CLANG=T given, but cannot find the clang compiler. Exiting") + endif + COMPILER := clang +endif +ifdef USE_GCC + ifeq ($(EXISTS_GCC),) + $(error "USE_GCC=T given, but cannot find the gcc compiler. Exiting") + endif + COMPILER := gcc +endif +ifeq ($(COMPILER),) + ifneq ($(EXISTS_CLANG),) + COMPILER := clang + else + COMPILER := gcc + endif +endif + +ifeq ($(COMPILER),gcc) + CC := gcc $(GCC_CFLAGS) +else + CC := clang $(CLANG_CFLAGS) +endif diff --git a/bin/linux-sdl.mk b/bin/linux-sdl.mk index 764d2fa..f24b3a9 100644 --- a/bin/linux-sdl.mk +++ b/bin/linux-sdl.mk @@ -10,5 +10,5 @@ XFILES = $(OBJECTDIR)sdl.o # XFLAGS = -DSDL=2 -XLDFLAGS = -lSDL2 +XLDFLAGS ?= -lSDL2 diff --git a/bin/makefile-cygwin.x86_64-sdl b/bin/makefile-cygwin.x86_64-sdl index 28531eb..2de38d5 100644 --- a/bin/makefile-cygwin.x86_64-sdl +++ b/bin/makefile-cygwin.x86_64-sdl @@ -1,26 +1,9 @@ # Options for Linux, Intel x86_64 and X-Window -CC = gcc -m64 $(GCC_CFLAGS) -I/usr/local/include -#CC = clang -m64 $(CLANG_CFLAGS) +GCC_CFLAGS := -m64 $(GCC_CFLAGS) -I/usr/local/include +CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) -I/usr/local/include +USE_DISPLAY=sdl +USE_LIBBSD=F +XLDFLAGS := -L/usr/local/lib -lSDL2 -XFILES = $(OBJECTDIR)sdl.o - -# -# For SDL version 2 -# -DSDL=2 in XFLAGS and -lSDL2 in LDFLAGS -# For SDL version 3 -# -DSDL=3 in XFLAGS and -lSDL3 in LDFLAGS -# -XFLAGS = -DSDL=2 - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) - -LDFLAGS = -lm -L/usr/local/lib -lSDL2 -# -LDELDFLAGS = - -OBJECTDIR = ../$(RELEASENAME)/ - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl +include linux-common.mk diff --git a/bin/makefile-cygwin.x86_64-x b/bin/makefile-cygwin.x86_64-x index 499d5d1..8747f35 100644 --- a/bin/makefile-cygwin.x86_64-x +++ b/bin/makefile-cygwin.x86_64-x @@ -1,28 +1,9 @@ -# Options for Linux, Intel x86_64 and X-Window +# Options for Cygwin, Intel x86_64 and X-Window -#CC = gcc -m64 $(GCC_CFLAGS) -CC = clang -m64 $(CLANG_CFLAGS) +GCC_CFLAGS := -m64 $(GCC_CFLAGS) +CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) +USE_DISPLAY=x +USE_LIBBSD=F -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o +include linux-common.mk - -XFLAGS = -DXWINDOW - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) - -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm - -OBJECTDIR = ../$(RELEASENAME)/ - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex diff --git a/bin/makefile-init-linux.aarch64 b/bin/makefile-init-linux.aarch64 index 3920d46..1e4502a 100644 --- a/bin/makefile-init-linux.aarch64 +++ b/bin/makefile-init-linux.aarch64 @@ -1,12 +1,9 @@ # Options for Linux, aarch64 processor, X windows, for INIT processing -include linux-x.mk - +OPTFLAGS = -O0 -g DEBUGFLAGS = ADDITIONAL_DFLAGS = $(DEBUGFLAGS) -DNOVERSION -DINIT +USE_LIBBSD=T +USE_DISPLAY=init include linux-common.mk - -OPTFLAGS = -O0 -g - -default : ../$(OSARCHNAME)/ldeinit diff --git a/bin/makefile-init-linux.x86_64 b/bin/makefile-init-linux.x86_64 index eb33754..bd2074a 100644 --- a/bin/makefile-init-linux.x86_64 +++ b/bin/makefile-init-linux.x86_64 @@ -1,12 +1,9 @@ # Options for Linux, x86 processor, X windows, for INIT processing -include linux-x.mk - +OPTFLAGS = -O0 -g DEBUGFLAGS = ADDITIONAL_DFLAGS = $(DEBUGFLAGS) -DNOVERSION -DINIT +USE_LIBBSD=T +USE_DISPLAY=init include linux-common.mk - -OPTFLAGS = -O0 -g - -default : ../$(OSARCHNAME)/ldeinit diff --git a/bin/makefile-init-wsl1.aarch64 b/bin/makefile-init-wsl1.aarch64 index 7fb5fce..d8e7051 100644 --- a/bin/makefile-init-wsl1.aarch64 +++ b/bin/makefile-init-wsl1.aarch64 @@ -1,29 +1,9 @@ # Options for Windows System for Linux v1, aarch64 processor, X windows, for INIT processing -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) - -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o - - -XFLAGS = -DXWINDOW - -# OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it OPTFLAGS = -O0 -g DEBUGFLAGS = -DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT -D__wsl1__ +ADDITIONAL_DFLAGS = $(DEBUGFLAGS) -DNOVERSION -DINIT -D__wsl1__ +USE_LIBBSD=T +USE_DISPLAY=init -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd - -OBJECTDIR = ../$(RELEASENAME)/ - -default : ../$(OSARCHNAME)/ldeinit +include linux-common.mk diff --git a/bin/makefile-init-wsl1.x86_64 b/bin/makefile-init-wsl1.x86_64 index a35a195..5f7a542 100644 --- a/bin/makefile-init-wsl1.x86_64 +++ b/bin/makefile-init-wsl1.x86_64 @@ -1,29 +1,9 @@ # Options for Windows System for Linux v1, Intel x86_64 processor, X windows, for INIT processing -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) - -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o - - -XFLAGS = -DXWINDOW - -# OPTFLAGS is normally -O2, for INIT we want unoptimized in case we need to debug it OPTFLAGS = -O0 -g DEBUGFLAGS = -DFLAGS = $(DEBUGFLAGS) $(XFLAGS) -DRELEASE=$(RELEASE) -DNOVERSION -DINIT -D__wsl1__ +ADDITIONAL_DFLAGS = $(DEBUGFLAGS) -DNOVERSION -DINIT -D__wsl1__ +USE_LIBBSD=T +USE_DISPLAY=init -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd - -OBJECTDIR = ../$(RELEASENAME)/ - -default : ../$(OSARCHNAME)/ldeinit +include linux-common.mk diff --git a/bin/makefile-linux.386-sdl b/bin/makefile-linux.386-sdl index 28b61fe..18c26fb 100644 --- a/bin/makefile-linux.386-sdl +++ b/bin/makefile-linux.386-sdl @@ -2,9 +2,7 @@ GCC_CFLAGS := -m64 $(GCC_CFLAGS) CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) - -include linux-sdl.mk +USE_DISPLAY=sdl +USE_LIBBSD=T include linux-common.mk - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl diff --git a/bin/makefile-linux.386-x b/bin/makefile-linux.386-x index 3ce00c4..0abcc25 100644 --- a/bin/makefile-linux.386-x +++ b/bin/makefile-linux.386-x @@ -2,9 +2,7 @@ GCC_CFLAGS := -m32 $(GCC_CFLAGS) CLANG_CFLAGS := -m32 $(CLANG_CFLAGS) - -include linux-x.mk +USE_DISPLAY=x +USE_LIBBSD=T include linux-common.mk - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex diff --git a/bin/makefile-linux.aarch64-sdl b/bin/makefile-linux.aarch64-sdl index dcf5c1d..4241218 100644 --- a/bin/makefile-linux.aarch64-sdl +++ b/bin/makefile-linux.aarch64-sdl @@ -1,7 +1,6 @@ # Options for Linux, ARM64 and SDL -include linux-sdl.mk +USE_DISPLAY=sdl +USE_LIBBSD=T include linux-common.mk - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl diff --git a/bin/makefile-linux.aarch64-x b/bin/makefile-linux.aarch64-x index 90ecd86..48bfc97 100644 --- a/bin/makefile-linux.aarch64-x +++ b/bin/makefile-linux.aarch64-x @@ -1,7 +1,6 @@ # Options for Linux, aarch64 and X-Window -include linux-x.mk +USE_DISPLAY=x +USE_LIBBSD=T include linux-common.mk - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex diff --git a/bin/makefile-linux.armv7l-sdl b/bin/makefile-linux.armv7l-sdl index 5d5f53a..2a31fca 100644 --- a/bin/makefile-linux.armv7l-sdl +++ b/bin/makefile-linux.armv7l-sdl @@ -1,7 +1,6 @@ # Options for Linux, ARMv7 and SDL -include linux-sdl.mk +USE_DISPLAY=sdl +USE_LIBBSD=T include linux-common.mk - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl diff --git a/bin/makefile-linux.armv7l-x b/bin/makefile-linux.armv7l-x index b113143..c69d063 100644 --- a/bin/makefile-linux.armv7l-x +++ b/bin/makefile-linux.armv7l-x @@ -1,7 +1,6 @@ # Options for Linux, ARMv7 and X-Window -include linux-x.mk +USE_DISPLAY=x +USE_LIBBSD=T include linux-common.mk - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex diff --git a/bin/makefile-linux.x86_64-sdl b/bin/makefile-linux.x86_64-sdl index 47698cb..396e303 100644 --- a/bin/makefile-linux.x86_64-sdl +++ b/bin/makefile-linux.x86_64-sdl @@ -2,9 +2,7 @@ GCC_CFLAGS := -m64 $(GCC_CFLAGS) CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) - -include linux-sdl.mk +USE_DISPLAY=sdl +USE_LIBBSD=T include linux-common.mk - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl diff --git a/bin/makefile-linux.x86_64-x b/bin/makefile-linux.x86_64-x index 6c9f398..7ffbb6b 100644 --- a/bin/makefile-linux.x86_64-x +++ b/bin/makefile-linux.x86_64-x @@ -2,9 +2,8 @@ GCC_CFLAGS := -m64 $(GCC_CFLAGS) CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) - -include linux-x.mk +USE_DISPLAY=x +USE_LIBBSD=T include linux-common.mk -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex diff --git a/bin/makefile-wsl1.aarch64-sdl b/bin/makefile-wsl1.aarch64-sdl index 7e756e9..c7ce045 100644 --- a/bin/makefile-wsl1.aarch64-sdl +++ b/bin/makefile-wsl1.aarch64-sdl @@ -1,25 +1,7 @@ # Options for Windows System for Linux v1, ARM64 and SDL -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) +USE_DISPLAY=sdl +USE_LIBBSD=T +ADDITIONAL_DFLAGS := -D__wsl1__ -XFILES = $(OBJECTDIR)sdl.o - -# -# For SDL version 2 -# -DSDL=2 in SDLFLAGS and -lSDL2 in LDFLAGS -# For SDL version 3 -# -DSDL=3 in SDLFLAGS and -lSDL3 in LDFLAGS -# -SDLFLAGS = -DSDL=2 - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(SDLFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ - -LDFLAGS = -lSDL2 -lm -lbsd -LDELDFLAGS = -lbsd - -OBJECTDIR = ../$(RELEASENAME)/ - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl +include linux-common.mk diff --git a/bin/makefile-wsl1.aarch64-x b/bin/makefile-wsl1.aarch64-x index fb57847..b742b42 100644 --- a/bin/makefile-wsl1.aarch64-x +++ b/bin/makefile-wsl1.aarch64-x @@ -1,27 +1,7 @@ # Options for Windows System for Linux v1, aarch64 and X-Window -CC = gcc $(GCC_CFLAGS) -#CC = clang $(CLANG_CFLAGS) +USE_DISPLAY=x +USE_LIBBSD=T +ADDITIONAL_DFLAGS := -D__wsl1__ -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o - -XFLAGS = -DXWINDOW - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ - -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd - -OBJECTDIR = ../$(RELEASENAME)/ - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex +include linux-common.mk diff --git a/bin/makefile-wsl1.x86_64-sdl b/bin/makefile-wsl1.x86_64-sdl index 5bad16a..6c6e045 100644 --- a/bin/makefile-wsl1.x86_64-sdl +++ b/bin/makefile-wsl1.x86_64-sdl @@ -1,25 +1,9 @@ # Options for Windows System for Linux v1, Intel x86_64 and SDL -CC = gcc -m64 $(GCC_CFLAGS) -# CC = clang -m64 $(CLANG_CFLAGS) +GCC_CFLAGS := -m64 $(GCC_CFLAGS) +CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) +USE_DISPLAY=sdl +USE_LIBBSD=T +ADDITIONAL_DFLAGS := -D__wsl1__ -XFILES = $(OBJECTDIR)sdl.o - -# -# For SDL version 2 -# -DSDL=2 in XFLAGS and -lSDL2 in LDFLAGS -# For SDL version 3 -# -DSDL=3 in XFLAGS and -lSDL3 in LDFLAGS -# -XFLAGS = -DSDL=2 - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ - -LDFLAGS = -lm -lSDL2 -lbsd -LDELDFLAGS = -lbsd - -OBJECTDIR = ../$(RELEASENAME)/ - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldesdl +include linux-common.mk diff --git a/bin/makefile-wsl1.x86_64-x b/bin/makefile-wsl1.x86_64-x index 6c12433..c1f5f3d 100644 --- a/bin/makefile-wsl1.x86_64-x +++ b/bin/makefile-wsl1.x86_64-x @@ -1,28 +1,9 @@ # Options for Windows System for Linux v1, Intel x86_64 and X-Window -CC = gcc -m64 $(GCC_CFLAGS) -# CC = clang -m64 $(CLANG_CFLAGS) +GCC_CFLAGS := -m64 $(GCC_CFLAGS) +CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) +USE_DISPLAY=x +USE_LIBBSD=T +ADDITIONAL_DFLAGS := -D__wsl1__ -XFILES = $(OBJECTDIR)xmkicon.o \ - $(OBJECTDIR)xbbt.o \ - $(OBJECTDIR)dspif.o \ - $(OBJECTDIR)xinit.o \ - $(OBJECTDIR)xscroll.o \ - $(OBJECTDIR)xcursor.o \ - $(OBJECTDIR)xlspwin.o \ - $(OBJECTDIR)xrdopt.o \ - $(OBJECTDIR)xwinman.o - - -XFLAGS = -DXWINDOW - -# OPTFLAGS is normally -O2. -OPTFLAGS = -O2 -g3 -DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) -D__wsl1__ - -LDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd -LDELDFLAGS = -L/usr/X11/lib -lX11 -lc -lm -lbsd - -OBJECTDIR = ../$(RELEASENAME)/ - -default : ../$(OSARCHNAME)/lde ../$(OSARCHNAME)/ldex +include linux-common.mk From 07e009cf08af3508d3abf0edcbedc93b405b868c Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Sat, 14 Mar 2026 19:37:40 -0700 Subject: [PATCH 08/19] Update github actions to latest versions to account for deprecation of node 20. --- .github/workflows/build.yml | 6 ++--- .github/workflows/buildBuilderImage.yml | 8 +++--- .github/workflows/buildRelease.yml | 34 ++++++++++++------------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5c24d78..33d17f8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: matrix: os: [macos-11, macos-12, ubuntu-22.04, ubuntu-20.04] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Install X11 dependencies on MacOS if: ${{ runner.os == 'macOS'}} run: brew install --cask xquartz @@ -28,7 +28,7 @@ jobs: # runs-on: [self-hosted, linux, ARM] # if: ${{ github.repository == 'Interlisp/maiko' }} # steps: -# - uses: actions/checkout@v3 +# - uses: actions/checkout@v6 # - name: Build # working-directory: bin # run: ./makeright x @@ -41,7 +41,7 @@ jobs: env: BUILD_TYPE: Release steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Show CMake version run: cmake --version - name: Install X11 dependencies on MacOS diff --git a/.github/workflows/buildBuilderImage.yml b/.github/workflows/buildBuilderImage.yml index 369bf1f..4805f6e 100644 --- a/.github/workflows/buildBuilderImage.yml +++ b/.github/workflows/buildBuilderImage.yml @@ -34,7 +34,7 @@ jobs: steps: # Checkout maiko - name: Checkout maiko - uses: actions/checkout@v3 + uses: actions/checkout@v6 # Setup docker environment variables - name: Setup Docker Environment Variables @@ -49,14 +49,14 @@ jobs: # Setup the Docker Machine Emulation environment. - name: Set up QEMU - uses: docker/setup-qemu-action@master + uses: docker/setup-qemu-action@v4 with: platforms: linux/amd64,linux/arm64,linux/arm/v7 # Setup the Docker Buildx funtion - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@master + uses: docker/setup-buildx-action@v4 # Login to ghcr.io - name: Login to GitHub Container Registry @@ -71,7 +71,7 @@ jobs: # - name: Build Docker Images for Push to GHCR if: ${{ true }} - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v7 with: builder: ${{ steps.buildx.outputs.name }} build-args: | diff --git a/.github/workflows/buildRelease.yml b/.github/workflows/buildRelease.yml index ce99828..ca9985f 100644 --- a/.github/workflows/buildRelease.yml +++ b/.github/workflows/buildRelease.yml @@ -123,7 +123,7 @@ jobs: steps: # Checkout the actions for this repo owner - name: Checkout Actions - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: ${{ github.repository_owner }}/.github path: ./Actions_${{ github.sha }} @@ -157,7 +157,7 @@ jobs: steps: # Checkout the actions for this repo owner - name: Checkout Actions - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: ${{ github.repository_owner }}/.github path: ./Actions_${{ github.sha }} @@ -165,7 +165,7 @@ jobs: # Checkout the branch - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 # Setup release tag - name: Setup Release Tag @@ -185,14 +185,14 @@ jobs: # Setup the Docker Machine Emulation environment. - name: Set up QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v4 with: platforms: linux/amd64,linux/arm64,linux/arm/v7 # Setup the Docker Buildx funtion - name: Set up Docker Buildx id: buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v4 # Do the Docker Build using the Dockerfile in the repository we # checked out. Save the results in a directory under /tmp to be used @@ -204,7 +204,7 @@ jobs: # Dockerfile, NOT HERE IN THE WORKFLOW. # - name: Build Docker Image and Save It Locally - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v7 with: builder: ${{ steps.buildx.outputs.name }} build-args: | @@ -246,7 +246,7 @@ jobs: # Push Release to github - name: Push the release - uses: ncipollo/release-action@v1 + uses: ncipollo/release-action@v1.21.0 with: allowUpdates: true artifacts: @@ -280,11 +280,11 @@ jobs: # Checkout the branch - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 # Checkout the actions for this repo owner - name: Checkout Actions - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: ${{ github.repository_owner }}/.github path: ./Actions_${{ github.sha }} @@ -376,7 +376,7 @@ jobs: # Push Release - name: Push the release - uses: ncipollo/release-action@v1 + uses: ncipollo/release-action@v1.21.0 with: allowUpdates: true artifacts: @@ -434,13 +434,13 @@ jobs: # Checkout the branch - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: path: cygwin\maiko # Checkout the actions for this repo owner - name: Checkout Actions - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: ${{ github.repository_owner }}/.github path: ./Actions_${{ github.sha }} @@ -470,7 +470,7 @@ jobs: # Push Release to github - name: Push the release - uses: ncipollo/release-action@v1 + uses: ncipollo/release-action@v1.21.0 with: allowUpdates: true artifacts: @@ -501,7 +501,7 @@ jobs: # Checkout the actions for this repo owner - name: Checkout Actions - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: ${{ github.repository_owner }}/.github path: ./Actions_${{ github.sha }} @@ -530,7 +530,7 @@ jobs: # Checkout the maiko branch - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 # Setup release tag - name: Setup Release Tag @@ -547,7 +547,7 @@ jobs: # Push Release to github - name: Push the release - uses: ncipollo/release-action@v1 + uses: ncipollo/release-action@v1.21.0 with: allowUpdates: true artifacts: ${{ steps.tag.outputs.release_tag }}-emscripten.tgz @@ -573,7 +573,7 @@ jobs: steps: # Checkout the actions for this repo owner - name: Checkout Actions - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: repository: ${{ github.repository_owner }}/.github path: ./Actions_${{ github.sha }} From 3430574f614fc63ad0c46f8a6429d94adebebb68 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Sat, 14 Mar 2026 20:43:13 -0700 Subject: [PATCH 09/19] More updates to github actions to account for deprecation of Node 20. --- .github/workflows/buildBuilderImage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildBuilderImage.yml b/.github/workflows/buildBuilderImage.yml index 4805f6e..9cc16a8 100644 --- a/.github/workflows/buildBuilderImage.yml +++ b/.github/workflows/buildBuilderImage.yml @@ -60,7 +60,7 @@ jobs: # Login to ghcr.io - name: Login to GitHub Container Registry - uses: docker/login-action@v2 + uses: docker/login-action@v4 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -71,7 +71,7 @@ jobs: # - name: Build Docker Images for Push to GHCR if: ${{ true }} - uses: docker/build-push-action@v7 + uses: docker/build-push-action@v7 with: builder: ${{ steps.buildx.outputs.name }} build-args: | From c6f3ba43054d72bf643a51ddc467fdcb30d8a428 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Tue, 17 Mar 2026 23:02:12 -0700 Subject: [PATCH 10/19] Including all suggestions made by Gemeni code check. Now includes linking to libbsd (if requested) only if glibc < version 2.38 since glibc >= 2.38 includes strlcat and friends. --- CMakeLists.txt | 23 +++++++++++++++++++---- bin/linux-common.mk | 21 ++++++++++++++++----- bin/linux-libbsd.mk | 14 ++++++++------ bin/makefile-linux.386-sdl | 4 ++-- 4 files changed, 45 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a1842d8..8f3d311 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -540,12 +540,27 @@ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/../" CACHE PATH "Installation prefix" FORCE) ENDIF() execute_process( - COMMAND sh -c "echo $(../bin/osversion).$(../bin/machinetype)" - OUTPUT_VARIABLE release_dir - WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMAND sh "${CMAKE_SOURCE_DIR}/bin/osversion" + OUTPUT_VARIABLE os_ver OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE res ) -INSTALL(TARGETS lde DESTINATION ${release_dir}) +if(NOT res EQUAL 0) + message(FATAL_ERROR "osversion script failed") +endif() + +execute_process( + COMMAND sh "${CMAKE_SOURCE_DIR}/bin/machinetype" + OUTPUT_VARIABLE machine_type + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE res +) +if(NOT res EQUAL 0) + message(FATAL_ERROR "machinetype script failed") +endif() + +set(release_dir "${os_ver}.${machine_type}")INSTALL(TARGETS lde DESTINATION ${release_dir}) + IF(MAIKO_DISPLAY_X11) INSTALL(TARGETS ldex ldeinit DESTINATION ${release_dir}) ENDIF() diff --git a/bin/linux-common.mk b/bin/linux-common.mk index 7129f74..d19943f 100644 --- a/bin/linux-common.mk +++ b/bin/linux-common.mk @@ -2,11 +2,17 @@ include linux-compiler.mk +BSD_CFLAGS := +BSD_LDFLAGS := ifeq ($(USE_LIBBSD),T) - include linux-libbsd.mk -else - BSD_CFLAGS := - BSD_LDFLAGS := + # Use LIBBSD - but only if glibc < 2.38 + # Because we only need strlcat, strlcpy and friends from libbsd + # and they are included in glibc from 2.38 on. + GLIBC_VERSION := $(shell ldd --version | head -1 | sed -e "s/^.*\([0-9]\.[0-9][0-9]\)/\\1/") + GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc) + ifneq ($(GLIBC_CHECK),1) + include linux-libbsd.mk + endif endif ifeq ($(USE_DISPLAY),x) @@ -26,7 +32,12 @@ OPTFLAGS ?= -O2 -g3 DFLAGS = $(XFLAGS) -DRELEASE=$(RELEASE) $(BSD_CFLAGS) $(ADDITIONAL_DFLAGS) LDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) -LDELDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) + +ifeq ($(USE_DISPLAY),x) + LDELDFLAGS = $(XLDFLAGS) -lc -lm $(BSD_LDFLAGS) +else + LDELDFLAGS = -lc -lm $(BSD_LDFLAGS) +endif OBJECTDIR = ../$(RELEASENAME)/ diff --git a/bin/linux-libbsd.mk b/bin/linux-libbsd.mk index 733a9f4..dde1ef9 100644 --- a/bin/linux-libbsd.mk +++ b/bin/linux-libbsd.mk @@ -4,7 +4,7 @@ ifneq ($(MAKECMDGOALS),clean) ifneq ($(MAKECMDGOALS),cleanup) - CHK_PKG_CONFIG := $(shell command -v pkg-config) + CHK_PKG_CONFIG := $(shell /bin/sh -c "command -v pkg-config") ifeq ($(CHK_PKG_CONFIG),) # pkg-config not found, print an error $(error "pkg-config not found. Please install it to build this project.") @@ -12,13 +12,15 @@ ifneq ($(MAKECMDGOALS),clean) CHK_LIBBSD_DEV := $(shell pkg-config --exists libbsd-overlay && echo true) ifneq ($(CHK_LIBBSD_DEV),true) - $(error "libbsd-dev (or libbsd-devel) package not found. Please install it to build this project.") + $(error "libbsd-dev (or libbsd-devel) package not found. Please install it to build this project.") endif - endif -endif -BSD_CFLAGS = $(shell pkg-config --cflags libbsd-overlay) + BSD_CFLAGS := $(shell pkg-config --cflags libbsd-overlay) + + BSD_LDFLAGS := $(shell pkg-config --libs libbsd-overlay) + + endif # clean +endif # cleanup -BSD_LDFLAGS = $(shell pkg-config --libs libbsd-overlay) diff --git a/bin/makefile-linux.386-sdl b/bin/makefile-linux.386-sdl index 18c26fb..f3f6365 100644 --- a/bin/makefile-linux.386-sdl +++ b/bin/makefile-linux.386-sdl @@ -1,7 +1,7 @@ # Options for Linux, Intel 386/486 and SDL -GCC_CFLAGS := -m64 $(GCC_CFLAGS) -CLANG_CFLAGS := -m64 $(CLANG_CFLAGS) +GCC_CFLAGS := -m32 $(GCC_CFLAGS) +CLANG_CFLAGS := -m32 $(CLANG_CFLAGS) USE_DISPLAY=sdl USE_LIBBSD=T From a26cafcbdab274f1a5f4c42e5a706f19a9f0d6b5 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Wed, 18 Mar 2026 00:01:24 -0700 Subject: [PATCH 11/19] Change USE_GCC=T/USE_CLANG=T to USE_COMPILER=clang/gcc for linux-y makefiles --- bin/linux-compiler.mk | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/bin/linux-compiler.mk b/bin/linux-compiler.mk index e147e8a..5bc17e5 100644 --- a/bin/linux-compiler.mk +++ b/bin/linux-compiler.mk @@ -9,28 +9,25 @@ EXISTS_CLANG := $(shell command -v clang) ifeq ($(or $(EXISTS_GCC),$(EXISTS_CLANG)),) $(error "Cannot find compiler: neither gcc nor clang. Exiting.") endif -ifneq ($(and $(USE_CLANG),$(USE_GCC)),) - $(error "Cannot use both USE_CLANG=T and USE_GCC=T. Exiting.") -endif COMPILER := -ifdef USE_CLANG +ifeq ($(USE_COMPILER),clang) ifeq ($(EXISTS_CLANG),) - $(error "USE_CLANG=T given, but cannot find the clang compiler. Exiting") + $(error "USE_COMPILER=clang, but cannot find the clang compiler. Exiting") endif COMPILER := clang -endif -ifdef USE_GCC +else ifeq ($(USE_COMPILER),gcc) ifeq ($(EXISTS_GCC),) - $(error "USE_GCC=T given, but cannot find the gcc compiler. Exiting") + $(error "USE_COMPILER=gcc given, but cannot find the gcc compiler. Exiting") endif COMPILER := gcc +else ifneq ($(EXISTS_CLANG),) + COMPILER := clang +else + COMPILER := gcc endif + ifeq ($(COMPILER),) - ifneq ($(EXISTS_CLANG),) - COMPILER := clang - else - COMPILER := gcc - endif + $(error "Oops. Trying to select gcc or clang but should never get here") endif ifeq ($(COMPILER),gcc) From 034c52b86fd32f0647a7941a02f9756230bf869b Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Wed, 18 Mar 2026 00:25:28 -0700 Subject: [PATCH 12/19] In CMakelists, limit use of libbsd for linux to cases where libc does not include strlcat --- CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8f3d311..0f01aa1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,9 +37,12 @@ IF(NEED_LIB_M) ENDIF() IF (CMAKE_SYSTEM_NAME STREQUAL "Linux") - find_package(PkgConfig REQUIRED) - pkg_check_modules(LIBBSD-OVERLAY REQUIRED IMPORTED_TARGET "libbsd-overlay") - SET(MAIKO_LIBRARIES ${MAIKO_LIBRARIES} PkgConfig::LIBBSD-OVERLAY) + CHECK_LIBRARY_EXISTS(c strlcat "" NO_NEED_FOR_LIBBSD) + IF(NOT NO_NEED_FOR_LIBBSD) + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBBSD-OVERLAY REQUIRED IMPORTED_TARGET "libbsd-overlay") + SET(MAIKO_LIBRARIES ${MAIKO_LIBRARIES} PkgConfig::LIBBSD-OVERLAY) + ENDIF() ENDIF() SET (MAIKO_RELEASE 351 CACHE STRING "Release version to build. Release: 115, 200, 201, 210, 300, 350, 351") @@ -559,7 +562,9 @@ if(NOT res EQUAL 0) message(FATAL_ERROR "machinetype script failed") endif() -set(release_dir "${os_ver}.${machine_type}")INSTALL(TARGETS lde DESTINATION ${release_dir}) +set(release_dir "${os_ver}.${machine_type}") + +INSTALL(TARGETS lde DESTINATION ${release_dir}) IF(MAIKO_DISPLAY_X11) INSTALL(TARGETS ldex ldeinit DESTINATION ${release_dir}) From 7a286a8f1f77b45fdc43eb3cf84f2ddb1692e9b0 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Wed, 18 Mar 2026 00:50:14 -0700 Subject: [PATCH 13/19] Fix sed script in linux-common.mk --- bin/linux-common.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/linux-common.mk b/bin/linux-common.mk index d19943f..6e76aec 100644 --- a/bin/linux-common.mk +++ b/bin/linux-common.mk @@ -8,7 +8,8 @@ ifeq ($(USE_LIBBSD),T) # Use LIBBSD - but only if glibc < 2.38 # Because we only need strlcat, strlcpy and friends from libbsd # and they are included in glibc from 2.38 on. - GLIBC_VERSION := $(shell ldd --version | head -1 | sed -e "s/^.*\([0-9]\.[0-9][0-9]\)/\\1/") + GLIBC_VERSION := $(shell ldd --version | head -1 | sed -e "s/^.* \([0-9]\.[0-9]\+\)/\\1/") + $(info xxxxxxx $(GLIBC_VERSION)) GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc) ifneq ($(GLIBC_CHECK),1) include linux-libbsd.mk From 1195048b1b060b004cc1ef6aef43e014fd0c458d Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Wed, 18 Mar 2026 00:51:03 -0700 Subject: [PATCH 14/19] Ooops. Took out debugging code. --- bin/linux-common.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/linux-common.mk b/bin/linux-common.mk index 6e76aec..23c4fb4 100644 --- a/bin/linux-common.mk +++ b/bin/linux-common.mk @@ -9,7 +9,6 @@ ifeq ($(USE_LIBBSD),T) # Because we only need strlcat, strlcpy and friends from libbsd # and they are included in glibc from 2.38 on. GLIBC_VERSION := $(shell ldd --version | head -1 | sed -e "s/^.* \([0-9]\.[0-9]\+\)/\\1/") - $(info xxxxxxx $(GLIBC_VERSION)) GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc) ifneq ($(GLIBC_CHECK),1) include linux-libbsd.mk From 6c20a5c6350620c057b8b6a3d922696b61a815a3 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Wed, 18 Mar 2026 01:03:32 -0700 Subject: [PATCH 15/19] Fixed comment in linux-compiler.mk --- bin/linux-compiler.mk | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/linux-compiler.mk b/bin/linux-compiler.mk index 5bc17e5..dc5b80e 100644 --- a/bin/linux-compiler.mk +++ b/bin/linux-compiler.mk @@ -1,8 +1,8 @@ # Select whether to use clang or gcc # Priority -# 1. If -DUSE_GCC or -DUSE_CLANG on command line (but not both) use the requested compiler. -# 2. If one compiler is installed but not the other, use the installed compiler. -# 3. Use clang +# 1. If USE_COMPILER=gcc or USE_COMPILER=clang on make command line use the requested compiler. +# 2. If clang is installed use it. +# 3. Use gcc EXISTS_GCC := $(shell command -v gcc) EXISTS_CLANG := $(shell command -v clang) From 54c81a3762c4a9d062efbe4f56d571049eab0231 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Wed, 18 Mar 2026 01:15:21 -0700 Subject: [PATCH 16/19] Fixed comment in linux-compiler.mk --- bin/linux-common.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/linux-common.mk b/bin/linux-common.mk index 23c4fb4..7a8afcf 100644 --- a/bin/linux-common.mk +++ b/bin/linux-common.mk @@ -8,7 +8,7 @@ ifeq ($(USE_LIBBSD),T) # Use LIBBSD - but only if glibc < 2.38 # Because we only need strlcat, strlcpy and friends from libbsd # and they are included in glibc from 2.38 on. - GLIBC_VERSION := $(shell ldd --version | head -1 | sed -e "s/^.* \([0-9]\.[0-9]\+\)/\\1/") + GLIBC_VERSION := $(shell getconf GNU_LIBC_VERSION | sed 's/glibc //') GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc) ifneq ($(GLIBC_CHECK),1) include linux-libbsd.mk From bbe011c583a239f749e8e6194b921682e4003db9 Mon Sep 17 00:00:00 2001 From: Frank Halasz Date: Wed, 18 Mar 2026 01:27:16 -0700 Subject: [PATCH 17/19] Take geminis suggestion on getting glibc version number in linux-common.mk --- bin/linux-common.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/linux-common.mk b/bin/linux-common.mk index 7a8afcf..3d56a0d 100644 --- a/bin/linux-common.mk +++ b/bin/linux-common.mk @@ -9,7 +9,10 @@ ifeq ($(USE_LIBBSD),T) # Because we only need strlcat, strlcpy and friends from libbsd # and they are included in glibc from 2.38 on. GLIBC_VERSION := $(shell getconf GNU_LIBC_VERSION | sed 's/glibc //') - GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc) + GLIBC_CHECK := 0 + ifneq ($(GLIBC_VERSION),) + GLIBC_CHECK := $(shell echo "$(GLIBC_VERSION) >= 2.38" | bc) + endif ifneq ($(GLIBC_CHECK),1) include linux-libbsd.mk endif From ee21e482a75b1b88e77fe040cf0d9b90c4eab7a0 Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 19 Mar 2026 11:16:16 -0700 Subject: [PATCH 18/19] Invoke "command" with /bin/sh -c from makefile to avoid not-found errors --- bin/linux-compiler.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/linux-compiler.mk b/bin/linux-compiler.mk index dc5b80e..18202f5 100644 --- a/bin/linux-compiler.mk +++ b/bin/linux-compiler.mk @@ -4,8 +4,8 @@ # 2. If clang is installed use it. # 3. Use gcc -EXISTS_GCC := $(shell command -v gcc) -EXISTS_CLANG := $(shell command -v clang) +EXISTS_GCC := $(shell /bin/sh -c command -v gcc) +EXISTS_CLANG := $(shell /bin/sh -c command -v clang) ifeq ($(or $(EXISTS_GCC),$(EXISTS_CLANG)),) $(error "Cannot find compiler: neither gcc nor clang. Exiting.") endif From 519c13891be4e1be078830ed7745987186f2b79d Mon Sep 17 00:00:00 2001 From: Nick Briggs Date: Thu, 19 Mar 2026 12:33:02 -0700 Subject: [PATCH 19/19] Fixes missing quoting for sh -c --- bin/linux-compiler.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/linux-compiler.mk b/bin/linux-compiler.mk index 18202f5..7a181f5 100644 --- a/bin/linux-compiler.mk +++ b/bin/linux-compiler.mk @@ -4,8 +4,8 @@ # 2. If clang is installed use it. # 3. Use gcc -EXISTS_GCC := $(shell /bin/sh -c command -v gcc) -EXISTS_CLANG := $(shell /bin/sh -c command -v clang) +EXISTS_GCC := $(shell /bin/sh -c "command -v gcc") +EXISTS_CLANG := $(shell /bin/sh -c "command -v clang") ifeq ($(or $(EXISTS_GCC),$(EXISTS_CLANG)),) $(error "Cannot find compiler: neither gcc nor clang. Exiting.") endif