From b567a2596989ea928cd208231cb5cf8f8806570c Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Thu, 9 Feb 2023 16:27:02 +0100 Subject: [PATCH] Zig build system updated: can compile static binaries. --- mk/makefile.static-build | 1 + zig/build.zig | 8 ++++++++ zig/makefile | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/mk/makefile.static-build b/mk/makefile.static-build index e9d7bf7..6f1818b 100644 --- a/mk/makefile.static-build +++ b/mk/makefile.static-build @@ -1,6 +1,7 @@ ifdef STATIC STATIC_BUILD ?= -static CRYSTAL_STATIC_BUILD ?= --static +ZIG_STATIC_BUILD ?= -Dstatic=true endif # For interactive completion in the shell. diff --git a/zig/build.zig b/zig/build.zig index a85554f..f3750fd 100644 --- a/zig/build.zig +++ b/zig/build.zig @@ -58,4 +58,12 @@ pub fn build(b: *std.Build) void { .optimize = optimize, }); link_and_install(pongd_exe); + + const is_static = b.option(bool, "static", "Compile static binaries.") orelse false; + if (is_static) { + ipcd_exe.linkage = .static; + tcpd_exe.linkage = .static; + pong_exe.linkage = .static; + pongd_exe.linkage = .static; + } } diff --git a/zig/makefile b/zig/makefile index def1897..83af35a 100644 --- a/zig/makefile +++ b/zig/makefile @@ -1,9 +1,11 @@ all: build +include ../mk/makefile.utils + update-libipc: git submodule update ZIG_OPTS ?= ZIG_OPTIM ?= ReleaseSafe build: - zig build -Doptimize=$(ZIG_OPTIM) $(ZIG_OPTS) + zig build -Doptimize=$(ZIG_OPTIM) $(ZIG_OPTS) $(ZIG_STATIC_BUILD)