This commit is contained in:
2026-07-13 12:28:59 +08:00
parent 6c3de4b2ef
commit f0fe5409fa
1409 changed files with 11369 additions and 413 deletions
+44 -28
View File
@@ -1,44 +1,60 @@
.DEFAULT_GOAL=help
.PHONY: clear linux win darwin release image image-push up down help
BINARY_NAME := iptvc
GOARCH ?= amd64
IMAGE_TAG ?= latest
GOARCH ?= $(shell go env GOARCH)
GOOS ?= $(shell go env GOOS)
## clean: Remove all compiled binaries
clean:
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//' || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
LDFLAGS := -s -w -X axenov/iptv-checker/app.VERSION=$(VERSION) -X axenov/iptv-checker/app.COMMIT=$(COMMIT)
# Internal build target
internal-build:
@rm -rf $(dir $(OUTPUT))
@mkdir -p $(dir $(OUTPUT))
@CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath -ldflags="$(LDFLAGS)" -o $(OUTPUT) .
@zip -j $(dir $(OUTPUT))../$(notdir $(patsubst %/,%,$(dir $(OUTPUT)))).zip $(OUTPUT) >/dev/null
@echo "Compiled: $(OUTPUT) ($(GOOS)/$(GOARCH))"
## clear = Remove all compiled binaries
clear:
@go clean
@rm -rf bin/
## linux: Build new binaries for linux
## build = Build binary for current platform
build:
@mkdir -p bin
@CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath -ldflags="$(LDFLAGS)" -o bin/$(BINARY_NAME) .
@echo "Compiled: bin/$(BINARY_NAME) ($(GOOS)/$(GOARCH))"
## linux = Build new binaries for linux
linux:
@rm -rf bin/linux_$(GOARCH)
@GOARCH=$(GOARCH) GOOS=linux go build -o bin/linux_$(GOARCH)/$(BINARY_NAME) .
@zip -j bin/linux_$(GOARCH).zip bin/linux_$(GOARCH)/$(BINARY_NAME)
@echo "Compiled: bin/linux_$(GOARCH)/$(BINARY_NAME) ($(GOARCH))"
@$(MAKE) internal-build GOOS=linux GOARCH=$(GOARCH) OUTPUT=bin/linux_$(GOARCH)/$(BINARY_NAME)
## win: Build new binaries for windows
## win = Build new binaries for windows
win:
@rm -rf bin/windows_$(GOARCH)
@GOARCH=$(GOARCH) GOOS=windows go build -o bin/windows_$(GOARCH)/$(BINARY_NAME).exe .
@zip -j bin/windows_$(GOARCH).zip bin/windows_$(GOARCH)/$(BINARY_NAME).exe
@echo "Compiled: bin/windows_$(GOARCH)/$(BINARY_NAME).exe ($(GOARCH))"
@$(MAKE) internal-build GOOS=windows GOARCH=$(GOARCH) OUTPUT=bin/windows_$(GOARCH)/$(BINARY_NAME).exe
## darwin: Build new binaries for darwin
## darwin = Build new binaries for darwin
darwin:
@rm -rf bin/darwin_$(GOARCH)
@GOARCH=$(GOARCH) GOOS=darwin go build -o bin/darwin_$(GOARCH)/$(BINARY_NAME) .
@zip -j bin/darwin_$(GOARCH).zip bin/darwin_$(GOARCH)/$(BINARY_NAME)
@echo "Compiled: bin/darwin_$(GOARCH)/$(BINARY_NAME) ($(GOARCH))"
@$(MAKE) internal-build GOOS=darwin GOARCH=$(GOARCH) OUTPUT=bin/darwin_$(GOARCH)/$(BINARY_NAME)
## release: Build all binaries and zip them
release: clean
@make linux GOARCH=amd64
@make linux GOARCH=arm64
@make win GOARCH=amd64
@make win GOARCH=arm64
@make darwin GOARCH=amd64
@make darwin GOARCH=arm64
## release = Build all binaries and zip them
release: clear
@$(MAKE) -j2 linux GOARCH=amd64
@$(MAKE) -j2 linux GOARCH=arm64
@$(MAKE) -j2 win GOARCH=amd64
@$(MAKE) -j2 win GOARCH=arm64
@$(MAKE) -j2 darwin GOARCH=amd64
@$(MAKE) -j2 darwin GOARCH=arm64
## help: Show this message and exit
## image = Build and push the Docker image
image:
@GOOS=$(GOOS) GOARCH=$(GOARCH) ./build-docker-image.sh $(IMAGE_TAG)
## help = Show this message and exit
help: Makefile
@echo "Available recipes:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@sed -n 's/^##/ /p' $< | column -t -s '='