Confirmed for OpenHSP v3.7.

ARG BASE=debian:bookworm
FROM ${BASE} AS buildenv
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
    --mount=type=cache,target=/var/lib/apt,sharing=locked \
    apt update && apt-get --no-install-recommends install -y \
    build-essential \
    g++ \
    libcurl4-openssl-dev \
    libegl1-mesa-dev \
    libffi-dev \
    libgles2-mesa-dev \
    libglew-dev \
    libgpiod-dev \
    libgtk2.0-dev \
    libsdl2-dev \
    libsdl2-image-dev \
    libsdl2-mixer-dev \
    libsdl2-ttf-dev \
    make \
    ;

FROM buildenv AS build
RUN mkdir /build
WORKDIR /src
RUN --mount=type=bind,target=.,rw=true \
    make -j$(nproc) && \
    cp -ar -t /build \
        common/ \
        hsp3cl \
        hsp3dish \
        hspcmp \
        hsphelp/ \
        hsphelp_en/ \
        hsptv/ \
        ipaexg.ttf \
        main.css \
        single.css \
    ;

FROM scratch AS final
COPY --from=build --link /build /

then, in the openhsp project directory, run

docker build . -o build/

It’s worth to note that trixie or newer debian, inherently, libgpiod later than v2.0 ruins the build because OpenHSP uses legacy functions in libgpiod that are removed at v2.0.

For debug build to enable gdb, you have to 1) add -ggdb3 or any similar flags to emit debugging information, and importantly, 2) remove the stripping flags -s that are hardcoded on the build sequence lines.

diff --git a/makefile b/makefile
index d27f7e4..bbe71ab 100644
--- a/makefile
+++ b/makefile
@@ -3,7 +3,7 @@ CXX = g++
 AR = ar
 
 # CFLAGS_ENV = # 32bit
-CFLAGS_ENV =  -DHSP64 # 64bit
+CFLAGS_ENV =  -ggdb3 -O0 -DHSP64 # 64bit
 CFLAGS_DISH = -Wno-write-strings --exec-charset=UTF-8 -DHSPDISH -DHSPLINUX -DHSPDEBUG -DUSE_OBAQ -DHSP_COM_UNSUPPORTED $(CFLAGS_ENV)
 CFLAGS_GP = -Wno-write-strings --exec-charset=UTF-8 -DHSPDISH -DHSPDISHGP -DHSPLINUX -DHSPDEBUG -DHSP_COM_UNSUPPORTED -DPNG_ARM_NEON_OPT=0 -I src/hsp3dish/extlib/src -I src/hsp3dish/extlib/src/glew -I src/hsp3dish/gameplay/src -std=c++11 $(CFLAGS_ENV)
 CFLAGS_CL = -Wno-write-strings -std=c++11 --exec-charset=UTF-8 -DHSPLINUX -DHSPDEBUG -DHSP_COM_UNSUPPORTED $(CFLAGS_ENV)
@@ -455,21 +455,21 @@ all: $(TARGETS)
 
 .SUFFIXES: .cpp
 hsp3dish: $(OBJS)
-	$(CXX) $(CFLAGS_DISH) $(OBJS) -s -o $@ $(LIBS1)
+	$(CXX) $(CFLAGS_DISH) $(OBJS) -o $@ $(LIBS1)
 %.do: %.c
 	$(CC) $(CFLAGS_DISH) -c $< -o $*.do
 %.do: %.cpp
 	$(CXX) $(CFLAGS_DISH) -c $< -o $*.do
 
 hsp3gp: $(OBJS_GP) $(LIBS_GP)
-	$(CXX) $(CFLAGS_GP) $(OBJS_GP) -s -o $@ $(LIBS2) $(LIBS_GP)
+	$(CXX) $(CFLAGS_GP) $(OBJS_GP) -o $@ $(LIBS2) $(LIBS_GP)
 %.gpo: %.c
 	$(CC) $(CFLAGS_GP) -c $< -o $*.gpo
 %.gpo: %.cpp
 	$(CXX) $(CFLAGS_GP) -c $< -o $*.gpo
 
 hspcmp: $(OBJS_CMP)
-	$(CXX) $(CFLAGS_CMP) $(OBJS_CMP) -s -o $@
+	$(CXX) $(CFLAGS_CMP) $(OBJS_CMP) -o $@
 %.o: %.c
 	$(CC) $(CFLAGS_CMP) -c $< -o $*.o
 %.o: %.cpp