2018-06-17 08:18:39 +08:00
|
|
|
NAME=clash
|
|
|
|
BINDIR=bin
|
2019-05-16 14:19:37 +08:00
|
|
|
VERSION=$(shell git describe --tags || echo "unknown version")
|
2019-03-23 19:24:26 +08:00
|
|
|
BUILDTIME=$(shell date -u)
|
2020-05-20 15:13:33 +08:00
|
|
|
GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags '-X "github.com/Dreamacro/clash/constant.Version=$(VERSION)" \
|
2019-03-23 19:24:26 +08:00
|
|
|
-X "github.com/Dreamacro/clash/constant.BuildTime=$(BUILDTIME)" \
|
2020-10-08 17:54:38 +08:00
|
|
|
-w -s -buildid='
|
2018-06-17 08:18:39 +08:00
|
|
|
|
2019-01-03 10:49:09 +08:00
|
|
|
PLATFORM_LIST = \
|
|
|
|
darwin-amd64 \
|
2022-03-19 13:42:06 +08:00
|
|
|
darwin-amd64-v3 \
|
2021-02-18 18:15:09 +08:00
|
|
|
darwin-arm64 \
|
2019-01-03 10:49:09 +08:00
|
|
|
linux-386 \
|
|
|
|
linux-amd64 \
|
2022-03-19 13:42:06 +08:00
|
|
|
linux-amd64-v3 \
|
2019-01-03 10:49:09 +08:00
|
|
|
linux-armv5 \
|
|
|
|
linux-armv6 \
|
|
|
|
linux-armv7 \
|
2022-09-21 21:17:59 +08:00
|
|
|
linux-arm64 \
|
2019-01-03 10:49:09 +08:00
|
|
|
linux-mips-softfloat \
|
|
|
|
linux-mips-hardfloat \
|
2019-07-26 18:45:50 +08:00
|
|
|
linux-mipsle-softfloat \
|
|
|
|
linux-mipsle-hardfloat \
|
2019-01-03 10:49:09 +08:00
|
|
|
linux-mips64 \
|
|
|
|
linux-mips64le \
|
2023-01-18 12:06:06 +08:00
|
|
|
linux-riscv64 \
|
2019-01-03 10:49:09 +08:00
|
|
|
freebsd-386 \
|
2021-04-26 20:42:17 +08:00
|
|
|
freebsd-amd64 \
|
2022-03-19 13:42:06 +08:00
|
|
|
freebsd-amd64-v3 \
|
2021-04-26 20:42:17 +08:00
|
|
|
freebsd-arm64
|
2018-06-17 08:18:39 +08:00
|
|
|
|
2019-01-03 10:49:09 +08:00
|
|
|
WINDOWS_ARCH_LIST = \
|
|
|
|
windows-386 \
|
2020-08-16 13:50:56 +08:00
|
|
|
windows-amd64 \
|
2022-03-19 13:42:06 +08:00
|
|
|
windows-amd64-v3 \
|
2021-08-18 13:26:23 +08:00
|
|
|
windows-arm64 \
|
2022-09-21 21:17:59 +08:00
|
|
|
windows-armv7
|
2019-01-03 10:49:09 +08:00
|
|
|
|
|
|
|
all: linux-amd64 darwin-amd64 windows-amd64 # Most used
|
2018-06-17 08:18:39 +08:00
|
|
|
|
2019-01-03 10:49:09 +08:00
|
|
|
darwin-amd64:
|
2022-03-19 13:42:06 +08:00
|
|
|
GOARCH=amd64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
darwin-amd64-v3:
|
2022-03-16 12:10:13 +08:00
|
|
|
GOARCH=amd64 GOOS=darwin GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
2018-06-17 08:18:39 +08:00
|
|
|
|
2021-02-18 18:15:09 +08:00
|
|
|
darwin-arm64:
|
|
|
|
GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
2019-01-03 10:49:09 +08:00
|
|
|
linux-386:
|
|
|
|
GOARCH=386 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
linux-amd64:
|
2022-03-19 13:42:06 +08:00
|
|
|
GOARCH=amd64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
linux-amd64-v3:
|
2022-03-16 12:10:13 +08:00
|
|
|
GOARCH=amd64 GOOS=linux GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
2019-01-03 10:49:09 +08:00
|
|
|
|
|
|
|
linux-armv5:
|
|
|
|
GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
linux-armv6:
|
|
|
|
GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
linux-armv7:
|
|
|
|
GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
2022-09-21 21:17:59 +08:00
|
|
|
linux-arm64:
|
2019-01-03 10:49:09 +08:00
|
|
|
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
linux-mips-softfloat:
|
|
|
|
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
linux-mips-hardfloat:
|
|
|
|
GOARCH=mips GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
2019-07-26 18:45:50 +08:00
|
|
|
linux-mipsle-softfloat:
|
|
|
|
GOARCH=mipsle GOMIPS=softfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
linux-mipsle-hardfloat:
|
|
|
|
GOARCH=mipsle GOMIPS=hardfloat GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
2019-01-03 10:49:09 +08:00
|
|
|
|
|
|
|
linux-mips64:
|
|
|
|
GOARCH=mips64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
linux-mips64le:
|
|
|
|
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
2023-01-18 12:06:06 +08:00
|
|
|
linux-riscv64:
|
|
|
|
GOARCH=riscv64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
2019-01-03 10:49:09 +08:00
|
|
|
freebsd-386:
|
|
|
|
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
freebsd-amd64:
|
2022-03-19 13:42:06 +08:00
|
|
|
GOARCH=amd64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
|
|
|
freebsd-amd64-v3:
|
2022-03-16 12:10:13 +08:00
|
|
|
GOARCH=amd64 GOOS=freebsd GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
2018-12-31 20:57:21 +08:00
|
|
|
|
2021-04-22 16:38:13 +08:00
|
|
|
freebsd-arm64:
|
|
|
|
GOARCH=arm64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
|
|
|
|
|
2019-01-03 10:49:09 +08:00
|
|
|
windows-386:
|
2019-02-15 23:43:28 +08:00
|
|
|
GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
|
2018-06-20 23:00:16 +08:00
|
|
|
|
2019-01-03 10:49:09 +08:00
|
|
|
windows-amd64:
|
2022-03-19 13:42:06 +08:00
|
|
|
GOARCH=amd64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
|
|
|
|
|
|
|
|
windows-amd64-v3:
|
2022-03-16 12:10:13 +08:00
|
|
|
GOARCH=amd64 GOOS=windows GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
|
2021-08-18 13:26:23 +08:00
|
|
|
|
|
|
|
windows-arm64:
|
|
|
|
GOARCH=arm64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
|
|
|
|
|
2022-09-21 21:17:59 +08:00
|
|
|
windows-armv7:
|
2020-08-16 13:50:56 +08:00
|
|
|
GOARCH=arm GOOS=windows GOARM=7 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
|
2019-01-03 10:49:09 +08:00
|
|
|
|
|
|
|
gz_releases=$(addsuffix .gz, $(PLATFORM_LIST))
|
|
|
|
zip_releases=$(addsuffix .zip, $(WINDOWS_ARCH_LIST))
|
|
|
|
|
|
|
|
$(gz_releases): %.gz : %
|
|
|
|
chmod +x $(BINDIR)/$(NAME)-$(basename $@)
|
2019-03-30 15:34:24 +08:00
|
|
|
gzip -f -S -$(VERSION).gz $(BINDIR)/$(NAME)-$(basename $@)
|
2019-01-03 10:49:09 +08:00
|
|
|
|
|
|
|
$(zip_releases): %.zip : %
|
2019-03-23 19:24:26 +08:00
|
|
|
zip -m -j $(BINDIR)/$(NAME)-$(basename $@)-$(VERSION).zip $(BINDIR)/$(NAME)-$(basename $@).exe
|
2019-01-03 10:49:09 +08:00
|
|
|
|
|
|
|
all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST)
|
2018-06-17 08:18:39 +08:00
|
|
|
|
2019-01-03 10:49:09 +08:00
|
|
|
releases: $(gz_releases) $(zip_releases)
|
2021-10-10 23:44:09 +08:00
|
|
|
|
2023-04-22 20:03:57 +08:00
|
|
|
LINT_OS_LIST := darwin windows linux freebsd openbsd
|
|
|
|
|
|
|
|
lint: $(foreach os,$(LINT_OS_LIST),$(os)-lint)
|
|
|
|
%-lint:
|
|
|
|
GOOS=$* golangci-lint run ./...
|
|
|
|
|
|
|
|
lint-fix: $(foreach os,$(LINT_OS_LIST),$(os)-lint-fix)
|
|
|
|
%-lint-fix:
|
|
|
|
GOOS=$* golangci-lint run --fix ./...
|
2021-10-10 23:44:09 +08:00
|
|
|
|
2018-06-17 08:18:39 +08:00
|
|
|
clean:
|
|
|
|
rm $(BINDIR)/*
|