-
Notifications
You must be signed in to change notification settings - Fork 7
/
common.mk
32 lines (28 loc) · 1.15 KB
/
common.mk
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
GOCC=go
DEBUG=0
GOOS=linux
ARCH=$(shell uname -m)
ifeq ($(ARCH),aarch64)
GC_ENV=GOOS=$(GOOS) GOARCH=arm64
else
GC_ENV=GOOS=$(GOOS) GOARCH=amd64
endif
RPMNAME := $(shell echo ${RPMNAME})
RPMRELEASE := $(shell echo ${RPMRELEASE})
RPMVERSION := $(shell echo ${RPMVERSION})
GITBRANCH := $(shell git rev-parse --abbrev-ref HEAD)
GITCOMMITID := $(shell git rev-parse HEAD)
BUILDTIME := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
NAMESPACE := github.com/ApsaraDB/db-monitor/common/utils
LDFLAGS = -X $(NAMESPACE).RpmName=$(RPMNAME) -X $(NAMESPACE).RpmRelease=$(RPMRELEASE) -X $(NAMESPACE).RpmVersion=$(RPMVERSION) -X $(NAMESPACE).GitBranch=$(GITBRANCH) -X $(NAMESPACE).Buildtime=$(BUILDTIME) -X $(NAMESPACE).GitCommitID=$(GITCOMMITID)
ifeq ($(DEBUG),1)
GC_COMMON_FLAGS= -gcflags=all="-N -l"
GC_LDFLAGS= -ldflags=-compressdwarf=false
GC_FLAGS=build -mod=vendor $(GC_LDFLAGS) $(GC_COMMON_FLAGS)
GC_PLUGIN_FLAGS=build -mod=vendor -buildmode=plugin $(GC_LDFLAGS) $(GC_COMMON_FLAGS)
else
GC_COMMON_FLAGS=
GC_LDFLAGS= -ldflags -w
GC_FLAGS=build -mod=vendor $(GC_LDFLAGS) $(GC_COMMON_FLAGS)
GC_PLUGIN_FLAGS=build -mod=vendor -buildmode=plugin $(GC_LDFLAGS) $(GC_COMMON_FLAGS)
endif