-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (31 loc) · 860 Bytes
/
Copy pathMakefile
File metadata and controls
39 lines (31 loc) · 860 Bytes
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
38
39
.PHONY:
.SILENT:
.DEFAULT_GOAL := run
BIN_NAME := p-router
VERSION ?= $(strip $(shell ./scripts/version.sh))
VERSION_NUMBER := $(strip $(shell ./scripts/version.sh number))
COMMIT_HASH := $(shell git rev-parse --short HEAD)
OUT_BIN ?= ./.bin/$(BIN_NAME)
GO_OPT_BASE := -ldflags "-X main.version=$(VERSION) $(GO_LDFLAGS) -X main.commitHash=$(COMMIT_HASH)"
BUILD_ENV := CGO_ENABLED=0
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
BUILD_ENV += GOOS=linux
endif
ifeq ($(UNAME_S), Darwin)
BUILD_ENV += GOOS=darwin
endif
UNAME_P := $(shell uname -p)
ifeq ($(UNAME_P),x86_64)
BUILD_ENV += GOARCH=amd64
endif
ifneq ($(filter arm%,$(UNAME_P)),)
BUILD_ENV += GOARCH=arm64
endif
build:
go mod download && $(BUILD_ENV) && go build $(GO_OPT_BASE) -o $(OUT_BIN) ./cmd/app
run: build
$(OUT_BIN) $(filter-out $@,$(MAKECMDGOALS))
# Empty goals trap
%:
@: