From 3d513e340f9ff25b9a016f03d07d25c58feb442a Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:07:25 +0200 Subject: [PATCH 1/3] Conditionally include X11 --- CMakeLists.txt | 12 +++++++++--- Makefile | 10 +++++++++- src/src/sdl3.c | 5 +++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39f275d..47e0e01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,10 +18,16 @@ INCLUDE ("cmake-common/misc-macros.cmake") SET (SDL_BUILDING_LIBRARY ON) FIND_PACKAGE (SDL3 REQUIRED) -FIND_PACKAGE (X11 REQUIRED) -SET (SAC2C_EXTRA_INC "-I${X11_INCLUDE_DIR}") -SET (SAC2C_CPP_INC "-Xl" "-lX11" "-Xtl" "-lX11") +# X11 is needed for X-forwarding over SSH +FIND_PACKAGE (X11 QUIET) + +IF (X11_FOUND) + MESSAGE (STATUS "X11 found") + SET (SAC2C_CC_FLAGS "-DHAVE_X11") + SET (SAC2C_EXTRA_INC "-I${X11_INCLUDE_DIR}") + SET (SAC2C_CPP_INC "-Xl" "-lX11" "-Xtl" "-lX11") +ENDIF () # Check if sac2c suppports building generically IF (BUILDGENERIC) diff --git a/Makefile b/Makefile index 2f360f3..619f79e 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SAC2C ?= sac2c TARGETS ?= "seq;mt_pth" BUILD_DIR ?= build -.PHONY: all build clean +.PHONY: all build examples clean all: build @@ -12,5 +12,13 @@ build: cmake -DSAC2C_EXEC=$(SAC2C) -DTARGETS=$(TARGETS) -B $(BUILD_DIR) cmake --build $(BUILD_DIR) +examples: $(BUILD_DIR)/mandelbrot $(BUILD_DIR)/minimal + +$(BUILD_DIR)/mandelbrot: examples/mandelbrot.sac + $(SAC2C) $< -o $@ + +$(BUILD_DIR)/minimal: examples/minimal.sac + $(SAC2C) $< -o $@ + clean: $(RM) -r $(BUILD_DIR) diff --git a/src/src/sdl3.c b/src/src/sdl3.c index 1d98062..dfb326e 100644 --- a/src/src/sdl3.c +++ b/src/src/sdl3.c @@ -2,7 +2,10 @@ #include #include #include + +#ifdef HAVE_X11 #include +#endif #include "sdl3.h" @@ -66,8 +69,10 @@ SDLcontext *SAC_InitDisplay(sac_int height, sac_int width) ctx->height = height; ctx->running = true; +#ifdef HAVE_X11 // Fix for using SDL with X-forwarding over SSH XInitThreads(); +#endif if (!SDL_Init(SDL_INIT_VIDEO)) { SAC_RuntimeError("SDL_Init failed: %s", SDL_GetError()); From d8c946be861cb953ce740caff57b01c349e5f7f3 Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:20:04 +0200 Subject: [PATCH 2/3] configure sac2c step might no longer be needed --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 76defec..f99f963 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,12 +8,12 @@ jobs: container: image: sacbase/sac-compiler steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@v7 with: submodules: 'recursive' - - name: Configure sac2c - run: cp -r /root/.sac2crc $HOME/.sac2crc - name: Install SDL3 run: apt install -y libsdl3-dev libsdl3-image-dev libsdl3-ttf-dev + - name: Setup CMake + run: cmake -DTARGETS="seq;mt_pth" -B build - name: Build - run: make + run: cmake --build build From f8b010acc57838d0e57212ebc94548ddd9493870 Mon Sep 17 00:00:00 2001 From: Jordy Aaldering <33897257+JordyAaldering@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:26:11 +0200 Subject: [PATCH 3/3] configure sac2c step might no longer be needed --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f99f963..91047aa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,8 @@ jobs: - uses: actions/checkout@v7 with: submodules: 'recursive' + - name: Configure sac2c + run: cp -r /root/.sac2crc $HOME/.sac2crc - name: Install SDL3 run: apt install -y libsdl3-dev libsdl3-image-dev libsdl3-ttf-dev - name: Setup CMake