-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (32 loc) · 1.01 KB
/
Makefile
File metadata and controls
37 lines (32 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
VER ?= $(VERSION)
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
LDFLAGS = -s -w \
-X "main.BuildTimestamp=$(shell date -u '+%Y-%m-%d %H:%M:%S')" \
-X "main.VERSION=$(VER)" \
-X "main.goVersion=$(shell go version | sed -r 's/go version go(.*)\ .*/\1/')"
GO := GO111MODULE=on CGO_ENABLED=0 go
GOLANGCI_LINT_VERSION = v1.61.0
APP_NAME := BPB-Wizard
OUT_DIR := bin
DIST_DIR := dist
.PHONY: build clean
build:
@mkdir -p $(OUT_DIR) $(DIST_DIR); \
if [ "$(GOOS)" = "windows" ]; then \
ext=".exe"; \
else \
ext=""; \
fi; \
echo "Building for $(GOOS)-$(GOARCH)..."; \
outdir="$(OUT_DIR)/$(APP_NAME)-$(GOOS)-$(GOARCH)"; \
GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build -trimpath -ldflags '$(LDFLAGS)' -o "$$outdir/$(APP_NAME)$$ext"; \
cp LICENSE $$outdir/; \
archive="$(DIST_DIR)/$(APP_NAME)-$(GOOS)-$(GOARCH)"; \
if [ "$(GOOS)" = "windows" ] || [ "$(GOOS)" = "darwin" ]; then \
zip -j -q $$archive.zip $$outdir/*; \
else \
tar -czf $$archive.tar.gz -C $$outdir/ .; \
fi;
clean:
@rm -rf $(OUT_DIR) $(DIST_DIR)