File Makefile of Package failed_cloudflared

# Minimal Makefile for building cloudflared in RPM build env.
# The original Makefile errored out when uname -m returned riscv64.
# This file adds minimal support for riscv64 by mapping it to GOARCH=riscv64
# and otherwise keeps a simple build rule so the RPM %build target can succeed.

UNAME := $(shell uname -m)
GO ?= go
GOOS ?= $(shell $(GO) env GOOS 2>/dev/null || echo linux)
BINARY := cloudflared
BUILD_DIR := bin

# Map host architecture to GOARCH. Add riscv64 support.
ifeq ($(UNAME),x86_64)
	GOARCH := amd64
else ifeq ($(UNAME),amd64)
	GOARCH := amd64
else ifeq ($(UNAME),aarch64)
	GOARCH := arm64
else ifeq ($(UNAME),armv7l)
	GOARCH := arm
else ifeq ($(UNAME),ppc64le)
	GOARCH := ppc64le
else ifeq ($(UNAME),s390x)
	GOARCH := s390x
else ifeq ($(UNAME),riscv64)
	GOARCH := riscv64
else
	$(error This system's architecture $(UNAME) isn't supported.)
endif

LDFLAGS ?=
BUILD_FLAGS ?=

.PHONY: all build clean install

all: build

build:
	@mkdir -p $(BUILD_DIR)
	@echo "Building for GOOS=$(GOOS) GOARCH=$(GOARCH)"
	@env GOOS=$(GOOS) GOARCH=$(GOARCH) $(GO) build -o $(BUILD_DIR)/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" ./cmd/cloudflared

clean:
	@rm -rf $(BUILD_DIR)

install: build
	@install -d $(DESTDIR)/usr/bin
	@install -m 0755 $(BUILD_DIR)/$(BINARY) $(DESTDIR)/usr/bin/$(BINARY)
openSUSE Build Service is sponsored by