-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
43 lines (36 loc) · 1.47 KB
/
Copy pathMakefile
File metadata and controls
43 lines (36 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
.PHONY: build release test clean help
VERSION := 0.1.0
BIN := fibercat-cli
DIST := dist
PLATS := darwin/arm64 darwin/amd64 linux/amd64 linux/arm64 linux/mipsle linux/mips windows/amd64
build: ## 当前平台 build(开发用)
go build -o $(BIN) .
@ls -la $(BIN)
release: clean ## 跨平台 release build(6 平台)
@mkdir -p $(DIST)
@for plat in $(PLATS); do \
os=$${plat%/*}; arch=$${plat#*/}; \
out="$(DIST)/$(BIN)-$(VERSION)-$$os-$$arch"; \
[ "$$os" = "windows" ] && out="$$out.exe"; \
echo "Building $$plat..."; \
GOOS=$$os GOARCH=$$arch go build -trimpath -ldflags="-s -w" -o "$$out" . || exit 1; \
done
@ls -la $(DIST)/
test: build ## 跑 smoke test(不依赖光猫)
@echo "=== help ===" && ./$(BIN) help | head -15
@echo "=== version ===" && ./$(BIN) version
mipsle-ipk: release build ## 把 fibercat-cli 自己打成 ipk(可塞进 ZTE 光猫跑)
@mkdir -p stage/usr/bin
@cp $(DIST)/$(BIN)-$(VERSION)-linux-mipsle stage/usr/bin/$(BIN)
@chmod +x stage/usr/bin/$(BIN)
@./$(BIN) ipk-build \
--name fibercat-cli --version $(VERSION)-1 --arch mipsel_24kc \
--staging stage \
--description "FiberCat CLI on the ONT itself (recursive)" \
--output $(DIST)/fibercat-cli_$(VERSION)-1_mipsel_24kc.ipk
@rm -rf stage
@ls -la $(DIST)/fibercat-cli_*.ipk
clean: ## 清产物
rm -rf $(DIST) $(BIN)
help: ## 此帮助
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'