diff --git a/Makefile b/Makefile index c96dcee36..aa5104ebe 100644 --- a/Makefile +++ b/Makefile @@ -10,13 +10,51 @@ ifeq (,$(VERSION)) endif endif +# process build tags +LEDGER_ENABLED ?= true +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 + +build_tags += $(BUILD_TAGS) +build_tags := $(strip $(build_tags)) + +whitespace := +whitespace += $(whitespace) +comma := , +build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) + # Update the ldflags with the app, client & server names ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=allora \ -X github.com/cosmos/cosmos-sdk/version.AppName=allorad \ -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.Commit=$(COMMIT) \ + -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" + +ldflags += $(LDFLAGS) +ldflags := $(strip $(ldflags)) -BUILD_FLAGS := -ldflags '$(ldflags)' +BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' BUILDDIR ?= $(CURDIR)/build ###########