-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
35 lines (27 loc) · 1.31 KB
/
Makefile
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
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
BUILD_DIR ?= $(CURDIR)/build
COMMIT := $(shell git log -1 --format='%H')
SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
###############################################################################
## Version ##
###############################################################################
ifeq (,$(VERSION))
VERSION := $(shell git describe --exact-match 2>/dev/null)
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif
###############################################################################
## Build / Install ##
###############################################################################
ldflags = -X github.com/ojo-network/ojotia/cmd.Commit=$(COMMIT) \
-X github.com/ojo-network/ojotia/cmd.SDKVersion=$(SDK_VERSION)
BUILD_FLAGS := -ldflags '$(ldflags)'
build: go.sum
@echo "--> Building..."
CGO_ENABLED=0 go build -mod=readonly -o $(BUILD_DIR)/ $(BUILD_FLAGS) ./...
install: go.sum
@echo "--> Installing..."
CGO_ENABLED=0 go install -mod=readonly $(BUILD_FLAGS) ./...
.PHONY: build install