Skip to content

Commit 6411d31

Browse files
makefile: add LDFLAGS environment variable. LDFLAGS default to empty string ("")
1 parent 345bf3d commit 6411d31

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
OS = darwin freebsd linux openbsd
22
ARCHS = 386 arm amd64 arm64
3+
LDFLAGS =
34

45
.DEFAULT_GOAL := help
56

@@ -10,7 +11,7 @@ help:
1011
all: build release release-windows
1112

1213
build: deps ## Build the project
13-
go build
14+
go build -ldflags="$(LDFLAGS)"
1415

1516
release: clean deps ## Generate releases for unix systems
1617
@for arch in $(ARCHS);\
@@ -19,7 +20,7 @@ release: clean deps ## Generate releases for unix systems
1920
do \
2021
echo "Building $$os-$$arch"; \
2122
mkdir -p build/webhook-$$os-$$arch/; \
22-
GOOS=$$os GOARCH=$$arch go build -o build/webhook-$$os-$$arch/webhook; \
23+
GOOS=$$os GOARCH=$$arch go build -ldflags="$(LDFLAGS)" -o build/webhook-$$os-$$arch/webhook; \
2324
tar cz -C build -f build/webhook-$$os-$$arch.tar.gz webhook-$$os-$$arch; \
2425
done \
2526
done
@@ -29,7 +30,7 @@ release-windows: clean deps ## Generate release for windows
2930
do \
3031
echo "Building windows-$$arch"; \
3132
mkdir -p build/webhook-windows-$$arch/; \
32-
GOOS=windows GOARCH=$$arch go build -o build/webhook-windows-$$arch/webhook.exe; \
33+
GOOS=windows GOARCH=$$arch go build -ldflags="$(LDFLAGS)" -o build/webhook-windows-$$arch/webhook.exe; \
3334
tar cz -C build -f build/webhook-windows-$$arch.tar.gz webhook-windows-$$arch; \
3435
done
3536

0 commit comments

Comments
 (0)