Skip to content

Commit f70025b

Browse files
committed
make statik build config via env var
1 parent ad14418 commit f70025b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ ifeq ($(HAS_GO), yes)
4848
CGO_CFLAGS ?= $(shell $(GO) env CGO_CFLAGS) $(CGO_EXTRA_CFLAGS)
4949
endif
5050

51+
CGO_ENABLED ?= 0
52+
ifneq (,$(findstring sqlite,$(TAGS)))
53+
CGO_ENABLED = 1
54+
endif
55+
56+
STATIC ?=
57+
EXTLDFLAGS ?=
58+
ifneq ($(STATIC),)
59+
EXTLDFLAGS = -extldflags "-static"
60+
endif
61+
5162
ifeq ($(GOOS),windows)
5263
IS_WINDOWS := yes
5364
else ifeq ($(patsubst Windows%,Windows,$(OS)),Windows)
@@ -746,7 +757,7 @@ security-check:
746757
go run $(GOVULNCHECK_PACKAGE) -show color ./...
747758

748759
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
749-
CGO_ENABLED=1 CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w -extldflags "-static" $(LDFLAGS)' -o $@
760+
CGO_ENABLED="$(CGO_ENABLED)" CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(EXTLDFLAGS) $(LDFLAGS)' -o $@
750761

751762
.PHONY: release
752763
release: frontend generate release-windows release-linux release-darwin release-freebsd release-copy release-compress vendor release-sources release-check

flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
GOROOT = "${go}/share/go";
4949

5050
TAGS = "sqlite sqlite_unlock_notify";
51+
STATIC = "true";
5152
};
5253
}
5354
);

0 commit comments

Comments
 (0)