61 lines
2.0 KiB
Makefile
61 lines
2.0 KiB
Makefile
.DEFAULT_GOAL=help
|
|
.PHONY: clear linux win darwin release image image-push up down help
|
|
|
|
BINARY_NAME := iptvc
|
|
IMAGE_TAG ?= latest
|
|
GOARCH ?= $(shell go env GOARCH)
|
|
GOOS ?= $(shell go env GOOS)
|
|
|
|
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/
|
|
|
|
## 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:
|
|
@$(MAKE) internal-build GOOS=linux GOARCH=$(GOARCH) OUTPUT=bin/linux_$(GOARCH)/$(BINARY_NAME)
|
|
|
|
## win = Build new binaries for windows
|
|
win:
|
|
@$(MAKE) internal-build GOOS=windows GOARCH=$(GOARCH) OUTPUT=bin/windows_$(GOARCH)/$(BINARY_NAME).exe
|
|
|
|
## darwin = Build new binaries for darwin
|
|
darwin:
|
|
@$(MAKE) internal-build GOOS=darwin GOARCH=$(GOARCH) OUTPUT=bin/darwin_$(GOARCH)/$(BINARY_NAME)
|
|
|
|
## 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
|
|
|
|
## 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 '='
|