forked from
hailey.at/cocoon
Vow, uncensorable PDS written in Go
1SHELL = /bin/bash
2.SHELLFLAGS = -o pipefail -c
3
4# Build output directory
5BUILD_DIR := dist
6
7# Platforms to build for
8PLATFORMS := \
9 linux/amd64 \
10 linux/arm64 \
11 linux/arm
12
13.PHONY: help
14help: ## Print info about all commands
15 @echo "Commands:"
16 @echo
17 @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[01;32m%-20s\033[0m %s\n", $$1, $$2}'
18
19.PHONY: build
20build: ## Build the vow binary
21 go build -o vow ./cmd/vow
22
23.PHONY: build-all
24build-all: ## Build binaries for all architectures
25 @echo "Building for all architectures..."
26 @mkdir -p $(BUILD_DIR)
27 @$(foreach platform,$(PLATFORMS), \
28 $(eval OS := $(word 1,$(subst /, ,$(platform)))) \
29 $(eval ARCH := $(word 2,$(subst /, ,$(platform)))) \
30 $(eval OUTPUT := $(BUILD_DIR)/vow-$(OS)-$(ARCH)) \
31 echo "Building $(OS)/$(ARCH)..."; \
32 GOOS=$(OS) GOARCH=$(ARCH) go build -o $(OUTPUT) ./cmd/vow && \
33 echo " ✓ $(OUTPUT)" || echo " ✗ Failed: $(OS)/$(ARCH)"; \
34 )
35 @echo "Done! Binaries are in $(BUILD_DIR)/"
36
37.PHONY: clean
38clean: ## Remove built binaries
39 rm -rf $(BUILD_DIR) vow
40
41.PHONY: run
42run: ## Build and run the PDS
43 go run ./cmd/vow run
44
45.PHONY: test
46test: ## Run tests
47 go clean -testcache && go test -v ./...
48
49.PHONY: lint
50lint: ## Verify code style and run static checks
51 go vet ./...
52 go fix ./...
53 test -z "$(shell gofmt -l ./...)"
54 golangci-lint run ./... --fix
55
56.PHONY: lint-install
57lint-install: ## Install golangci-lint
58 go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
59
60.PHONY: fmt
61fmt: ## Format code
62 go fmt ./...
63
64.PHONY: check
65check: ## Compile everything, checking syntax (does not output binaries)
66 go build ./...
67
68.PHONY: docker-build
69docker-build: ## Build the Docker image
70 docker build -t vow .