mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-10 02:53:12 +00:00
148 lines
3.9 KiB
Makefile
148 lines
3.9 KiB
Makefile
NAME=sing-box
|
|
BINDIR=bin
|
|
VERSION=$(shell date +%Y%m%d).$(shell git rev-parse --short HEAD)
|
|
BUILDTIME=$(shell LANG=en_US.UTF-8 date -u)
|
|
GOBUILD=CGO_ENABLED=0 go build -v -tags '$(TAGS)' -trimpath -ldflags '-X "github.com/sagernet/sing-box/constant.Version=$(VERSION)" \
|
|
-X "github.com/sagernet/sing-box/constant.BuildTime=$(BUILDTIME)" \
|
|
-w -s -buildid='
|
|
MAIN=./cmd/sing-box
|
|
|
|
PLATFORM_LIST = \
|
|
darwin-amd64 \
|
|
darwin-amd64-v3 \
|
|
darwin-arm64 \
|
|
linux-386 \
|
|
linux-amd64 \
|
|
linux-amd64-v3 \
|
|
linux-armv5 \
|
|
linux-armv6 \
|
|
linux-armv7 \
|
|
linux-armv8 \
|
|
linux-mips-softfloat \
|
|
linux-mips-hardfloat \
|
|
linux-mipsle-softfloat \
|
|
linux-mipsle-hardfloat \
|
|
linux-mips64 \
|
|
linux-mips64le \
|
|
freebsd-386 \
|
|
freebsd-amd64 \
|
|
freebsd-amd64-v3 \
|
|
freebsd-arm64
|
|
|
|
WINDOWS_ARCH_LIST = \
|
|
windows-386 \
|
|
windows-amd64 \
|
|
windows-amd64-v3 \
|
|
windows-arm64 \
|
|
windows-arm32v7
|
|
|
|
all: linux-amd64 darwin-amd64 windows-amd64
|
|
|
|
docker:
|
|
$(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
darwin-amd64:
|
|
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
darwin-amd64-v3:
|
|
GOARCH=amd64 GOOS=darwin GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
darwin-arm64:
|
|
GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-386:
|
|
GOARCH=386 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-amd64:
|
|
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-amd64-v3:
|
|
GOARCH=amd64 GOOS=linux GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-armv5:
|
|
GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-armv6:
|
|
GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-armv7:
|
|
GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-armv8:
|
|
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-mips-softfloat:
|
|
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-mips-hardfloat:
|
|
GOARCH=mips GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-mipsle-softfloat:
|
|
GOARCH=mipsle GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-mipsle-hardfloat:
|
|
GOARCH=mipsle GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-mips64:
|
|
GOARCH=mips64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
linux-mips64le:
|
|
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
freebsd-386:
|
|
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
freebsd-amd64:
|
|
GOARCH=amd64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
freebsd-amd64-v3:
|
|
GOARCH=amd64 GOOS=freebsd GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
freebsd-arm64:
|
|
GOARCH=arm64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@ $(MAIN)
|
|
|
|
windows-386:
|
|
GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
|
|
windows-amd64:
|
|
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
|
|
windows-amd64-v3:
|
|
GOARCH=amd64 GOOS=windows GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
|
|
windows-arm64:
|
|
GOARCH=arm64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
|
|
windows-arm32v7:
|
|
GOARCH=arm GOOS=windows GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe $(MAIN)
|
|
|
|
gz_releases=$(addsuffix .gz, $(PLATFORM_LIST))
|
|
zip_releases=$(addsuffix .zip, $(WINDOWS_ARCH_LIST))
|
|
|
|
ifeq ($(LATEST),true)
|
|
PACKVERSION=latest
|
|
else
|
|
PACKVERSION=$(VERSION)
|
|
endif
|
|
|
|
$(gz_releases): %.gz : %
|
|
chmod +x $(BINDIR)/$(NAME)-$(basename $@)
|
|
gzip -f -S -$(PACKVERSION).gz $(BINDIR)/$(NAME)-$(basename $@)
|
|
|
|
$(zip_releases): %.zip : %
|
|
zip -m -j $(BINDIR)/$(NAME)-$(basename $@)-$(PACKVERSION).zip $(BINDIR)/$(NAME)-$(basename $@).exe
|
|
|
|
all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST)
|
|
|
|
releases: $(gz_releases) $(zip_releases)
|
|
|
|
lint:
|
|
GOOS=darwin golangci-lint run ./...
|
|
GOOS=windows golangci-lint run ./...
|
|
GOOS=linux golangci-lint run ./...
|
|
GOOS=freebsd golangci-lint run ./...
|
|
GOOS=openbsd golangci-lint run ./...
|
|
|
|
clean:
|
|
rm $(BINDIR)/*
|