main
6d86999 · 6 months ago 26 commits
 1# Go settings
 2GO        := go
 3GOOS      ?= linux
 4GOARCH    ?= amd64
 5BINARY    ?= ufWall
 6BIN_DIR   := bin
 7SRC       := ./cmd/ufWall
 8LDFLAGS   := -s -w
 9
10.PHONY: all help build run clean dist
11
12all: build
13
14help:
15	@echo "ufWall Makefile Utilities"
16	@echo "  help      -- Show this message (default)"
17	@echo "  build     -- Build binary into $(BIN_DIR)/$(BINARY)"
18	@echo "  run       -- Run the binary (sudo required, uses $(BIN_DIR)/$(BINARY))"
19	@echo "  clean     -- Remove the ./bin directory"
20	@echo "  dist      -- Create a .tar.gz with a statically‑linked binary"
21
22build:
23	@mkdir -p $(BIN_DIR)
24	$(GO) build \
25		-ldflags="$(LDFLAGS)" \
26		-o $(BIN_DIR)/$(BINARY) \
27		$(SRC)
28
29run: build
30	@sudo $(BIN_DIR)/$(BINARY)
31
32clean:
33	@rm -rf $(BIN_DIR) dist
34
35dist: clean build
36	@mkdir -p dist
37	@cp $(BIN_DIR)/$(BINARY) dist/
38	@cp README.md dist/
39	@tar czf dist/$(BINARY)-$(GOOS)-$(GOARCH).tar.gz -C dist $(BINARY) README.md
40	@echo "Distribution packaged in dist/$(BINARY)-$(GOOS)-$(GOARCH).tar.gz"