Skip to content

Commit

Permalink
feat: statically link on build via Makefile and add version
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyberezansky committed Oct 29, 2024
1 parent 649b7fc commit fcc3d80
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PKGPATH=$(BUILDPATH)/pkg

GO=$(shell which go)
GOGET=$(GO) get
VERSION ?= 0.4.0

PLATFORMS := darwin/amd64 linux/amd64 freebsd/amd64 darwin/arm64 linux/arm64
PLATFORM = $(subst /, ,$@)
Expand Down Expand Up @@ -54,7 +55,7 @@ default: prepare build
$(PLATFORMS):
@echo -n "build $(OS)/$(ARCH)... "
$(eval EXT := $(shell if [ "$(OS)" = "windows" ]; then echo .exe; fi))
@GOOS=$(OS) GOARCH=$(ARCH) $(GOBUILD) -o $(BINPATH)/$(EXENAME)_$(OS)_$(ARCH)$(EXT) $(CMDSOURCES)
@GOOS=$(OS) GOARCH=$(ARCH) $(GOBUILD) -a -o $(BINPATH)/$(EXENAME)_$(OS)_$(ARCH)$(EXT) -ldflags '-X main.Version=v'$(VERSION)' -extldflags "-static"' $(CMDSOURCES)
@echo ok

all: default $(PLATFORMS)

0 comments on commit fcc3d80

Please sign in to comment.