motorino/Makefile

25 lines
842 B
Makefile

# SPDX-License-Identifier: GPL-3.0-or-later
GO ?= go
MODULE := git.kmalloc.org/squid/motorino
VERSION ?= dev
LDFLAGS := -s -w -X $(MODULE)/internal/version.value=$(VERSION)
.PHONY: check build dist
# check runs the formatter check, the vet, staticcheck and the tests.
check:
@test -z "$$(gofmt -l .)" || { echo "gofmt needed on:"; gofmt -l .; exit 1; }
$(GO) vet ./...
staticcheck ./...
$(GO) test ./...
# build compiles a local binary into bin/motorino.
build:
$(GO) build -trimpath -ldflags "$(LDFLAGS)" -o bin/motorino ./cmd/motorino
# dist compiles the release binary for the server and writes its SHA-256.
dist:
mkdir -p dist
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO) build -trimpath -ldflags "$(LDFLAGS)" -o dist/motorino-linux-amd64 ./cmd/motorino
cd dist && sha256sum motorino-linux-amd64 > motorino-linux-amd64.sha256