Skip to content

Commit

Permalink
based on Cosmos SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulBernal authored Apr 23, 2021
1 parent 493d766 commit ea14c12
Showing 1 changed file with 99 additions and 18 deletions.
117 changes: 99 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,105 @@
VERSION := $(shell echo $(shell git describe --tags))
#!/usr/bin/make -f

BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
COMMIT := $(shell git log -1 --format='%H')
APP_NAME := "bcnad"
UNAME_OS := $(shell uname -s)
UNAME_ARCH := $(shell uname -m)
name := "bcnad"

all: build
# don't override user values
ifeq (,$(VERSION))
VERSION := $(shell git describe --tags | sed 's/^v//')
# if VERSION is empty, then populate it with branch's name and raw commit hash
ifeq (,$(VERSION))
VERSION := $(BRANCH)-$(COMMIT)
endif
endif

PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation')
LEDGER_ENABLED ?= true
SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::') # grab everything after the space in "github.com/tendermint/tendermint v0.34.7"
DOCKER := $(shell which docker)
BUILDDIR ?= $(CURDIR)/build
TEST_DOCKER_REPO=jackzampolin/gaiatest

export GO111MODULE = on

# process build tags

build_tags = netgo
ifeq ($(LEDGER_ENABLED),true)
ifeq ($(OS),Windows_NT)
GCCEXE = $(shell where gcc.exe 2> NUL)
ifeq ($(GCCEXE),)
$(error gcc.exe not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
else
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),OpenBSD)
$(warning OpenBSD detected, disabling ledger support (https://github.com/cosmos/cosmos-sdk/issues/1988))
else
GCC = $(shell command -v gcc 2> /dev/null)
ifeq ($(GCC),)
$(error gcc not installed for ledger support, please install or set LEDGER_ENABLED=false)
else
build_tags += ledger
endif
endif
endif
endif

ifeq (cleveldb,$(findstring cleveldb,$(GAIA_BUILD_OPTIONS)))
build_tags += gcc cleveldb
endif
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))

whitespace :=
whitespace += $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))

# process linker flags

ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=bcna \
-X github.com/cosmos/cosmos-sdk/version.AppName=bcnad \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)

ifeq (cleveldb,$(findstring cleveldb,$(GAIA_BUILD_OPTIONS)))
ldflags += -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb
endif
ifeq (,$(findstring nostrip,$(GAIA_BUILD_OPTIONS)))
ldflags += -w -s
endif
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))

BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)'
# check for nostrip option
ifeq (,$(findstring nostrip,$(GAIA_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
endif

#$(info $$BUILD_FLAGS is [$(BUILD_FLAGS)])

# The below include contains the tools target.
include contrib/devtools/Makefile

###############################################################################
### Documentation ###
###############################################################################

all: install lint test

build:
$(eval override VERSION = $(shell git describe --tags))
$(eval override DATE = $(shell date))
$(eval override HOST = $(shell hostname))
$(eval override COMMIT = $(shell git log -1 --format='%H'))
GO111MODULE=on go build -o bin/bcnad ./cmd/bcnad
BUILD_TARGETS := build install

win64:
GOOS=windows GOARCH=amd64 GO111MODULE=on go build -o bin/main-windows-amd64 ./cmd/bcnad
build: BUILD_ARGS=-o $(BUILDDIR)/

win32:
GOOS=windows GOARCH=386 GO111MODULE=on go build -o bin/main-windows-386 ./cmd/bcnad
$(BUILD_TARGETS): go.sum $(BUILDDIR)/
go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./...

mac:
GOOS=darwin GOARCH=amd64 GO111MODULE=on go build -o bin/main-darwin-amd64 ./cmd/bcnad
$(BUILDDIR)/:
mkdir -p $(BUILDDIR)/

0 comments on commit ea14c12

Please sign in to comment.