Makefile: deduplicate binaries

Signed-off-by: Roman Khimov <roman@nspcc.ru>
This commit is contained in:
Roman Khimov 2021-05-20 12:52:58 +03:00
parent 4e8412b86c
commit e622f1987b
8 changed files with 6 additions and 17 deletions

View file

@ -5,36 +5,25 @@ REPO ?= $(shell go list -m)
VERSION ?= "$(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD | sed 's/^v//')" VERSION ?= "$(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD | sed 's/^v//')"
BINDIR = bin BINDIR = bin
# s3 gw variables # Binaries to build
BIN_NAME=neofs-s3-gw CMDS = $(addprefix neofs-, $(notdir $(wildcard cmd/*)))
BIN = "$(BINDIR)/$(BIN_NAME)" BINS = $(addprefix $(BINDIR)/, $(CMDS))
# Variables for docker # Variables for docker
HUB_IMAGE ?= "nspccdev/$(BIN_NAME)" HUB_IMAGE ?= "nspccdev/$(BIN_NAME)"
HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')" HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')"
# Authmate variables
AUTHMATE_BIN_NAME=neofs-authmate
AUTHMATE_BIN = "$(BINDIR)/$(AUTHMATE_BIN_NAME)"
.PHONY: help all dep clean format test cover lint docker/lint image-push image dirty-image .PHONY: help all dep clean format test cover lint docker/lint image-push image dirty-image
# Make all binaries # Make all binaries
all: $(BIN) $(AUTHMATE_BIN) all: $(BINS)
$(BIN): $(BINDIR) dep $(BINS): $(BINDIR) dep
@echo "⇒ Build $@" @echo "⇒ Build $@"
CGO_ENABLED=0 \ CGO_ENABLED=0 \
go build -v -trimpath \ go build -v -trimpath \
-ldflags "-X main.Version=$(VERSION)" \ -ldflags "-X main.Version=$(VERSION)" \
-o $@ ./cmd/gate -o $@ ./cmd/$(subst neofs-,,$(notdir $@))
$(AUTHMATE_BIN): $(BINDIR) dep
@echo "⇒ Build $@"
CGO_ENABLED=0 \
go build -v -trimpath \
-ldflags "-X main.Version=$(VERSION)" \
-o $@ ./cmd/authmate
$(BINDIR): $(BINDIR):
@echo "⇒ Ensure dir: $@" @echo "⇒ Ensure dir: $@"