diff --git a/Dockerfile b/Dockerfile index 19b101a626..d83c546c1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ FROM docker.io/golang:1.21.0-alpine3.17 as builder RUN apk update && apk add --no-cache \ gcc \ git \ + # linux-headers are needed for Ledger support + linux-headers \ make \ musl-dev COPY . /celestia-app diff --git a/Makefile b/Makefile index 92c0ade341..db9fbe93b8 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,42 @@ DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bu IMAGE := ghcr.io/tendermint/docker-build-proto:latest DOCKER_PROTO_BUILDER := docker run -v $(shell pwd):/workspace --workdir /workspace $(IMAGE) PROJECTNAME=$(shell basename "$(PWD)") +LEDGER_ENABLED ?= true + + +# process build tags +build_tags = +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 := $(strip $(build_tags)) + +empty := +whitespace := $(empty) $(empty) +comma := , + +# convert build_tags from a whitespace seperated list to a comma seperated list +build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags)) + # process linker flags ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=celestia-app \ @@ -14,7 +50,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=celestia-app \ -X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" ldflags += $(LDFLAGS) -BUILD_FLAGS := -ldflags '$(ldflags)' +BUILD_FLAGS := -tags "$(build_tags)" -ldflags '$(ldflags)' ## help: Get more info on make commands. help: Makefile