build: Makefile with cross-builds (linux/termux arm64, armv7), non-root distroless Dockerfile, example config

This commit is contained in:
OpenClaw Dev 2026-10-25 03:15:32 +01:00
parent 24e4bbe3d1
commit 8896bdc963
4 changed files with 103 additions and 0 deletions

46
Makefile Normal file
View file

@ -0,0 +1,46 @@
BINARY := openclaw
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
GOFLAGS := -trimpath
DIST := dist
export CGO_ENABLED := 0
.PHONY: all build test vet race run cross linux-amd64 linux-arm64 linux-armv7 android-arm64 android-armv7 docker clean
all: vet test build
build:
go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o bin/$(BINARY) ./cmd/openclaw
test:
go test ./...
race:
CGO_ENABLED=1 go test -race ./...
vet:
go vet ./...
run: build
./bin/$(BINARY) -config config.yaml
cross: linux-amd64 linux-arm64 linux-armv7 android-arm64 android-armv7
linux-amd64:
GOOS=linux GOARCH=amd64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(DIST)/$(BINARY)-linux-amd64 ./cmd/openclaw
linux-arm64:
GOOS=linux GOARCH=arm64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(DIST)/$(BINARY)-linux-arm64 ./cmd/openclaw
linux-armv7:
GOOS=linux GOARCH=arm GOARM=7 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(DIST)/$(BINARY)-linux-armv7 ./cmd/openclaw
# Termux on Android: GOOS=android, pure Go (no NDK needed thanks to CGO_ENABLED=0)
android-arm64:
GOOS=android GOARCH=arm64 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(DIST)/$(BINARY)-termux-arm64 ./cmd/openclaw
# android/arm needs cgo+NDK; a static linux/arm binary runs fine in Termux instead.
android-armv7:
GOOS=linux GOARCH=arm GOARM=7 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(DIST)/$(BINARY)-termux-armv7 ./cmd/openclaw
docker:
docker build -t openclaw:$(VERSION) .
clean:
rm -rf bin $(DIST)