diff --git a/Makefile b/Makefile index f24c2996a..9c8b4fcb6 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ BRANCH = "master" REPONAME = "neo-go" NETMODE ?= "privnet" -BINARY=./bin/neo-go$(shell go env GOEXE) +BINARY=neo-go +BINARY_PATH=./bin/$(BINARY)$(shell go env GOEXE) +GO_VERSION ?= 1.18 DESTDIR = "" SYSCONFIGDIR = "/etc" BINDIR = "/usr/bin" @@ -22,7 +24,7 @@ IMAGE_REPO=nspccdev/neo-go # All of the targets are phony here because we don't really use make dependency # tracking for files -.PHONY: build bin deps image image-latest image-push image-push-latest check-version clean-cluster push-tag \ +.PHONY: build $(BINARY) deps image docker/$(BINARY) image-latest image-push image-push-latest check-version clean-cluster push-tag \ test vet lint fmt cover build: deps @@ -30,9 +32,18 @@ build: deps @set -x \ && export GOGC=off \ && export CGO_ENABLED=0 \ - && go build -trimpath -v -ldflags $(BUILD_FLAGS) -o ${BINARY} ./cli/main.go + && go build -trimpath -v -ldflags $(BUILD_FLAGS) -o ${BINARY_PATH} ./cli/main.go -bin: build +$(BINARY): build + +docker/$(BINARY): + @echo "=> Building binary using clean Docker environment" + @docker run --rm -t \ + -v `pwd`:/src \ + -w /src \ + -u "$$(id -u):$$(id -g)" \ + --env HOME=/src \ + golang:$(GO_VERSION) make $(BINARY) neo-go.service: neo-go.service.template @sed -r -e 's_BINDIR_$(BINDIR)_' -e 's_UNITWORKDIR_$(UNITWORKDIR)_' -e 's_SYSCONFIGDIR_$(SYSCONFIGDIR)_' $< >$@ @@ -45,7 +56,7 @@ install: build neo-go.service && cp ./config/protocol.mainnet.yml $(DESTDIR)$(SYSCONFIGDIR)/neo-go \ && cp ./config/protocol.privnet.yml $(DESTDIR)$(SYSCONFIGDIR)/neo-go \ && cp ./config/protocol.testnet.yml $(DESTDIR)$(SYSCONFIGDIR)/neo-go \ - && install -m 0755 -t $(BINDIR) $(BINARY) \ + && install -m 0755 -t $(BINDIR) $(BINARY_PATH) \ postinst: install @echo "=> Preparing directories and configs"