agent/Makefile

48 lines
1.5 KiB
Makefile
Raw Permalink Normal View History

2025-03-30 09:13:46 +08:00
GO ?= go # if using docker, should not need to be installed/linked
GOBINREL = build/bin
GOBIN = $(CURDIR)/$(GOBINREL)
UNAME = $(shell uname) # Supported: Darwin, Linux
CGO_CFLAGS := $(shell $(GO) env CGO_CFLAGS 2>/dev/null) # don't lose default
# If it is arm64 or aarch64, then we need to use portable version of blst. use or with stringw "arm64" and "aarch64" to support both
ifeq ($(shell uname -m), arm64)
CGO_CFLAGS += -D__BLST_PORTABLE__
endif
ifeq ($(shell uname -m), aarch64)
CGO_CFLAGS += -D__BLST_PORTABLE__
endif
CGO_CFLAGS += -Wno-unknown-warning-option -Wno-enum-int-mismatch -Wno-strict-prototypes -Wno-unused-but-set-variable -O3
CGO_LDFLAGS := $(shell $(GO) env CGO_LDFLAGS 2> /dev/null)
CGO_LDFLAGS += -O3 -g
ifeq ($(shell uname -s), Darwin)
ifeq ($(filter-out 13.%,$(shell sw_vers --productVersion)),)
CGO_LDFLAGS += -mmacosx-version-min=13.3
endif
endif
GO_FLAGS += -trimpath -tags $(BUILD_TAGS) -buildvcs=false
GO_FLAGS += -ldflags '-extldflags "-Wl,--allow-multiple-definition"'
GOBUILD = CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" GOPRIVATE="$(GOPRIVATE)" $(GO) build $(GO_FLAGS)
default: all
## go-version: print and verify go version
go-version:
@if [ $(shell $(GO) version | cut -c 16-17) -lt 20 ]; then \
echo "minimum required Golang version is 1.20"; \
exit 1 ;\
fi
agent:
$(GOBUILD) -o $(GOBIN)/agent ./src/main.go
# build each command using %.cmd rule
$(COMMANDS): %: %.cmd
## all:
all: agent $(COMMANDS)