Skip to content

Commit 11bcc31

Browse files
authored
Merge pull request #573 from jnovy/348
Add optional systemd support for static builds
2 parents b91d4ee + 270aa5a commit 11bcc31

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@ override CFLAGS += $(shell $(PKG_CONFIG) --cflags glib-2.0) -DVERSION=\"$(VERSIO
3838
# "pkg-config --exists" will error if the package doesn't exist. Make can only compare
3939
# output of commands, so the echo commands are to allow pkg-config to error out, make to catch it,
4040
# and allow the compilation to complete.
41+
#
42+
# For static builds, systemd can be disabled with DISABLE_SYSTEMD=1
43+
ifneq ($(DISABLE_SYSTEMD), 1)
4144
ifeq ($(shell $(PKG_CONFIG) --exists libsystemd && echo "0"), 0)
4245
override LIBS += $(shell $(PKG_CONFIG) --libs libsystemd)
4346
override CFLAGS += $(shell $(PKG_CONFIG) --cflags libsystemd) -D USE_JOURNALD=1
4447
endif
48+
endif
4549

4650
ifeq ($(shell hack/seccomp-notify.sh), 0)
4751
override LIBS += $(shell $(PKG_CONFIG) --libs libseccomp) -ldl

nix/derivation.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{ stdenv
22
, pkgs
3+
, enableSystemd ? false
34
}:
45
with pkgs; stdenv.mkDerivation rec {
56
name = "conmon";
@@ -18,11 +19,15 @@ with pkgs; stdenv.mkDerivation rec {
1819
] ++ [
1920
pkgsStatic.glib
2021
libseccomp
22+
] ++ lib.optionals enableSystemd [
23+
# Only include systemd for dynamic builds, not static builds
24+
# Static builds will use PKG_CONFIG_PATH approach instead
2125
];
2226
prePatch = ''
2327
export CFLAGS='-static -pthread'
2428
export LDFLAGS='-s -w -static-libgcc -static'
2529
export EXTRA_LDFLAGS='-s -w -linkmode external -extldflags "-static -lm"'
30+
${lib.optionalString (!enableSystemd) "export DISABLE_SYSTEMD=1"}
2631
'';
2732
buildPhase = ''
2833
patchShebangs .

0 commit comments

Comments
 (0)