Skip to content

Commit 4966fa5

Browse files
authored
Merge pull request #92 from kcp-dev/enable-debugging
allow to set $DEBUG_BUILD to build a binary with debugging symbols
2 parents 59f097e + 99257a9 commit 4966fa5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@ GIT_VERSION = $(shell git describe --tags --always --match='v*')
2222
LDFLAGS += -extldflags '-static' \
2323
-X github.com/kcp-dev/api-syncagent/internal/version.gitVersion=$(GIT_VERSION) \
2424
-X github.com/kcp-dev/api-syncagent/internal/version.gitHead=$(GIT_HEAD)
25+
LDFLAGS_EXTRA ?= -w
26+
27+
ifdef DEBUG_BUILD
28+
GOFLAGS = -mod=readonly
29+
LDFLAGS_EXTRA =
30+
GOTOOLFLAGS_EXTRA = -gcflags=all="-N -l"
31+
endif
32+
2533
BUILD_DEST ?= _build
26-
GOTOOLFLAGS ?= $(GOBUILDFLAGS) -ldflags '-w $(LDFLAGS)' $(GOTOOLFLAGS_EXTRA)
34+
GOTOOLFLAGS ?= $(GOBUILDFLAGS) -ldflags '$(LDFLAGS) $(LDFLAGS_EXTRA)' $(GOTOOLFLAGS_EXTRA)
2735
GOARCH ?= $(shell go env GOARCH)
2836
GOOS ?= $(shell go env GOOS)
2937

0 commit comments

Comments
 (0)