# LibreForts build helpers — thin wrappers around the Podman workflow. # # Everything COMPILES inside the container (Fedora + every dependency prebuilt # in /usr/local, see Containerfile). The binary RUNS on the host, which supplies # SDL3 and a display. `make run` does both halves in the right place. # # Recipe lines are indented with TABs; make requires it. IMAGE := forts-clone-dev BUILDDIR := builddir BIN := $(BUILDDIR)/forts-clone # Run a command in the dev image with the repo bind-mounted at /src. PODMAN_RUN := podman run --rm -v "$(CURDIR)":/src:Z --userns=keep-id \ localhost/$(IMAGE):latest bash -c .DEFAULT_GOAL := build .PHONY: help image build reconfigure run check check-lua sim-check shell clean clean-image help: @echo "LibreForts:" @echo " make image build the Podman dev image (once, and after" @echo " editing Containerfile)" @echo " make build compile in the container (default target)" @echo " make run compile, then run the game on the host" @echo " make check compile + validate the Lua data (do this before" @echo " claiming a change works)" @echo " make check-lua validate the Lua data only" @echo " make sim-check settle every map headlessly, fail if a fort" @echo " collapses (SOAK=seconds)" @echo " make reconfigure re-run meson setup, after editing meson.build" @echo " make shell interactive shell in the dev container" @echo " make clean remove $(BUILDDIR)" @echo " make clean-image remove the Podman dev image" image: podman build -t $(IMAGE) . # Configures builddir on first use, then compiles. Re-running is cheap. build: $(PODMAN_RUN) 'cd /src && { [ -f $(BUILDDIR)/build.ninja ] || \ meson setup $(BUILDDIR); } && meson compile -C $(BUILDDIR)' # meson refuses a plain re-setup on a configured dir; this is the escape hatch. reconfigure: $(PODMAN_RUN) 'cd /src && meson setup $(BUILDDIR) --reconfigure && \ meson compile -C $(BUILDDIR)' # Runs on the HOST, from the repo root: data/ is resolved relative to CWD. run: build ./$(BIN) check: build check-lua sim-check # Settles every map headlessly and fails if a fort loses struts. Catches # "the fort collapses on load" without a display. SOAK=seconds. SOAK ?= 5 sim-check: build ./$(BUILDDIR)/sim_check $(SOAK) # The GUI cannot run headless here, so parsing the Lua is the other half of # "it works". Mods are validated LAYERED (base file first), because they # table.insert into globals the base defines — running one alone always fails. check-lua: @command -v lua >/dev/null 2>&1 || \ { echo "check-lua: no 'lua' on the host, skipping"; exit 0; } @set -e; \ for f in data/*.lua; do \ lua -e "dofile('$$f')"; \ echo " OK $$f"; \ done; \ for f in data/mods/*/*.lua; do \ [ -e "$$f" ] || continue; \ base="data/$$(basename "$$f")"; \ if [ -f "$$base" ]; then \ lua -e "dofile('$$base'); dofile('$$f')"; \ echo " OK $$f (layered on $$base)"; \ else \ lua -e "dofile('$$f')"; \ echo " OK $$f"; \ fi; \ done shell: podman run --rm -it -v "$(CURDIR)":/src:Z --userns=keep-id \ localhost/$(IMAGE):latest bash clean: rm -rf $(BUILDDIR) clean-image: -podman rmi localhost/$(IMAGE):latest