Skip to content

Commit

Permalink
link static
Browse files Browse the repository at this point in the history
  • Loading branch information
nothub committed Mar 8, 2023
1 parent 2295aca commit 5779216
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ MOD_NAME = $(shell go list -m)
BIN_NAME = $(shell basename $(MOD_NAME))
GIT_TAG = $(shell git describe --tags --abbrev=0 --dirty --match v[0-9]* 2> /dev/null || echo "v0.0.0-indev")
VERSION = $(GIT_TAG:v%=%)
LDFLAGS = -ldflags="-X '$(MOD_NAME)/version=$(VERSION)'"
GOFLAGS = -tags osusergo,netgo
LDFLAGS = -ldflags="-w -extldflags=-static -X '$(MOD_NAME)/version=$(VERSION)'"

out/$(BIN_NAME): $(shell ls go.mod go.sum *.go)
$(info dev build of $(VERSION))
go build $(LDFLAGS) -race -o out/$(BIN_NAME)
go build $(GOFLAGS) -race $(LDFLAGS) -o out/$(BIN_NAME)

.PHONY: release
release: clean
$(info release builds of $(VERSION))
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-amd64
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-arm64
GOOS=linux GOARCH=amd64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-amd64
GOOS=linux GOARCH=arm64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_linux-arm64
./deb.sh $(VERSION) amd64
./deb.sh $(VERSION) arm64
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-amd64
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-arm64
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_windows-amd64.exe
GOOS=darwin GOARCH=amd64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-amd64
GOOS=darwin GOARCH=arm64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_darwin-arm64
GOOS=windows GOARCH=amd64 go build $(GOFLAGS) $(LDFLAGS) -o out/$(BIN_NAME)_$(VERSION)_windows-amd64.exe

.PHONY: clean
clean:
Expand Down

0 comments on commit 5779216

Please sign in to comment.