diff --git a/Makefile b/Makefile index df0f1b074..10ccf6e09 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ NAME := gdu PACKAGE := github.com/dundee/$(NAME) VERSION := $(shell git describe --tags) GOFLAGS ?= -buildmode=pie -trimpath -mod=readonly -modcacherw -LDFLAGS := "-s -w \ +LDFLAGS := "-s -w -extldflags '-static' \ -X '$(PACKAGE)/build.Version=$(VERSION)' \ -X '$(PACKAGE)/build.User=$(shell id -u -n)' \ -X '$(PACKAGE)/build.Time=$(shell LC_ALL=en_US.UTF-8 date)'" @@ -13,26 +13,28 @@ run: build: @echo "Version: " $(VERSION) mkdir -p dist - GOFLAGS="$(GOFLAGS)" go build -ldflags=$(LDFLAGS) -o dist/$(NAME) . + GOFLAGS="$(GOFLAGS)" CGO_ENABLED=0 go build -a -ldflags=$(LDFLAGS) -o dist/$(NAME) . build-all: @echo "Version: " $(VERSION) -mkdir dist - -gox \ + -CGO_ENABLED=0 gox \ -os="darwin windows" \ -arch="amd64" \ -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" \ -ldflags=$(LDFLAGS) - -gox \ + -CGO_ENABLED=0 gox \ -os="linux freebsd netbsd openbsd" \ -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" \ -ldflags=$(LDFLAGS) - cd dist; GOOS=linux GOARM=5 GOARCH=arm go build -ldflags=$(LDFLAGS) -o gdu_linux_armv5l .. - cd dist; GOOS=linux GOARM=6 GOARCH=arm go build -ldflags=$(LDFLAGS) -o gdu_linux_armv6l .. - cd dist; GOOS=linux GOARM=7 GOARCH=arm go build -ldflags=$(LDFLAGS) -o gdu_linux_armv7l .. - cd dist; GOOS=linux GOARCH=arm64 go build -ldflags=$(LDFLAGS) -o gdu_linux_arm64 .. + cd dist; GOFLAGS="$(GOFLAGS)" CGO_ENABLED=0 go build -a -ldflags=$(LDFLAGS) -o gdu_linux_amd64 .. + + cd dist; CGO_ENABLED=0 GOOS=linux GOARM=5 GOARCH=arm go build -ldflags=$(LDFLAGS) -o gdu_linux_armv5l .. + cd dist; CGO_ENABLED=0 GOOS=linux GOARM=6 GOARCH=arm go build -ldflags=$(LDFLAGS) -o gdu_linux_armv6l .. + cd dist; CGO_ENABLED=0 GOOS=linux GOARM=7 GOARCH=arm go build -ldflags=$(LDFLAGS) -o gdu_linux_armv7l .. + cd dist; CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags=$(LDFLAGS) -o gdu_linux_arm64 .. cd dist; for file in gdu_linux_* gdu_darwin_* gdu_netbsd_* gdu_openbsd_* gdu_freebsd_*; do tar czf $$file.tgz $$file; done cd dist; for file in gdu_windows_*; do zip $$file.zip $$file; done