Clash.Meta/Makefile

166 lines
4.1 KiB
Makefile
Raw Normal View History

2023-11-03 21:01:45 +08:00
NAME=mihomo
2021-12-03 20:38:40 +08:00
BINDIR=bin
2022-05-02 00:59:41 +08:00
BRANCH=$(shell git branch --show-current)
ifeq ($(BRANCH),Alpha)
VERSION=alpha-$(shell git rev-parse --short HEAD)
2022-05-02 00:59:41 +08:00
else ifeq ($(BRANCH),Beta)
VERSION=beta-$(shell git rev-parse --short HEAD)
2022-05-02 14:43:01 +08:00
else ifeq ($(BRANCH),)
2022-05-02 00:59:41 +08:00
VERSION=$(shell git describe --tags)
else
VERSION=$(shell git rev-parse --short HEAD)
2022-05-02 00:59:41 +08:00
endif
2019-03-23 19:24:26 +08:00
BUILDTIME=$(shell date -u)
2023-11-03 21:01:45 +08:00
GOBUILD=CGO_ENABLED=0 go build -tags with_gvisor -trimpath -ldflags '-X "github.com/metacubex/mihomo/constant.Version=$(VERSION)" \
-X "github.com/metacubex/mihomo/constant.BuildTime=$(BUILDTIME)" \
2021-12-03 20:38:40 +08:00
-w -s -buildid='
2018-06-17 08:18:39 +08:00
2019-01-03 10:49:09 +08:00
PLATFORM_LIST = \
2024-02-05 13:56:39 +08:00
darwin-amd64-compatible \
darwin-amd64 \
darwin-arm64 \
linux-amd64-compatible \
linux-amd64 \
linux-armv5 \
linux-armv6 \
linux-armv7 \
2022-03-09 05:08:35 +08:00
linux-arm64 \
linux-mips64 \
linux-mips64le \
linux-mips-softfloat \
linux-mips-hardfloat \
linux-mipsle-softfloat \
linux-mipsle-hardfloat \
linux-riscv64 \
linux-loong64 \
2022-03-18 00:40:39 +08:00
android-arm64 \
freebsd-386 \
freebsd-amd64 \
freebsd-arm64
2021-12-04 19:59:41 +08:00
2019-01-03 10:49:09 +08:00
WINDOWS_ARCH_LIST = \
2021-12-03 20:38:40 +08:00
windows-386 \
windows-amd64-compatible \
windows-amd64 \
windows-arm64 \
windows-arm32v7
2021-12-04 19:59:41 +08:00
all:linux-amd64 linux-arm64\
darwin-amd64 darwin-arm64\
windows-amd64 windows-arm64\
2022-03-17 23:57:58 +08:00
darwin-all: darwin-amd64 darwin-arm64
2021-12-03 20:38:40 +08:00
docker:
GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2020-06-21 12:38:14 +08:00
darwin-amd64:
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
darwin-amd64-compatible:
GOARCH=amd64 GOOS=darwin GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2022-03-19 15:01:49 +08:00
darwin-arm64:
2021-12-03 20:38:40 +08:00
GOARCH=arm64 GOOS=darwin $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2019-01-03 10:49:09 +08:00
linux-386:
2021-12-03 20:38:40 +08:00
GOARCH=386 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2019-01-03 10:49:09 +08:00
linux-amd64:
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-amd64-compatible:
GOARCH=amd64 GOOS=linux GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2021-12-04 14:34:01 +08:00
linux-arm64:
GOARCH=arm64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2021-12-03 20:38:40 +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)-$@
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)-$@
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)-$@
linux-mips64:
GOARCH=mips64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-mips64le:
GOARCH=mips64le GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2023-03-01 13:41:25 +08:00
linux-riscv64:
GOARCH=riscv64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
linux-loong64:
GOARCH=loong64 GOOS=linux $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2023-03-01 13:41:25 +08:00
Merge remote-tracking branch 'yaling888/with-tun' into Alpha # Conflicts: # .github/workflows/codeql-analysis.yml # .github/workflows/linter.yml # .github/workflows/release.yml # Makefile # README.md # adapter/outbound/vless.go # component/geodata/memconservative/cache.go # component/geodata/router/condition.go # component/geodata/router/condition_geoip.go # component/geodata/standard/standard.go # component/geodata/utils.go # config/config.go # config/initial.go # constant/metadata.go # constant/path.go # constant/rule.go # constant/rule_extra.go # dns/client.go # dns/filters.go # dns/resolver.go # go.mod # go.sum # hub/executor/executor.go # hub/route/configs.go # listener/listener.go # listener/tproxy/tproxy_linux_iptables.go # listener/tun/dev/dev.go # listener/tun/dev/dev_darwin.go # listener/tun/dev/dev_linux.go # listener/tun/dev/dev_windows.go # listener/tun/dev/wintun/config.go # listener/tun/dev/wintun/dll_windows.go # listener/tun/dev/wintun/session_windows.go # listener/tun/dev/wintun/wintun_windows.go # listener/tun/ipstack/commons/dns.go # listener/tun/ipstack/gvisor/tun.go # listener/tun/ipstack/gvisor/tundns.go # listener/tun/ipstack/gvisor/utils.go # listener/tun/ipstack/stack_adapter.go # listener/tun/ipstack/system/dns.go # listener/tun/ipstack/system/tcp.go # listener/tun/ipstack/system/tun.go # listener/tun/tun_adapter.go # main.go # rule/common/base.go # rule/common/domain.go # rule/common/domain_keyword.go # rule/common/domain_suffix.go # rule/common/final.go # rule/common/geoip.go # rule/common/geosite.go # rule/common/ipcidr.go # rule/common/port.go # rule/parser.go # rule/process.go # test/go.mod # test/go.sum # transport/vless/xtls.go # tunnel/tunnel.go
2022-03-17 17:41:02 +08:00
android-arm64:
2023-01-15 15:04:27 +08:00
GOARCH=arm64 GOOS=android $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2022-02-21 18:04:38 +08:00
2021-12-03 20:38:40 +08:00
freebsd-386:
GOARCH=386 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
freebsd-amd64:
2022-03-16 12:10:13 +08:00
GOARCH=amd64 GOOS=freebsd GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2021-12-03 20:38:40 +08:00
freebsd-arm64:
GOARCH=arm64 GOOS=freebsd $(GOBUILD) -o $(BINDIR)/$(NAME)-$@
2019-01-03 10:49:09 +08:00
windows-386:
2021-12-03 20:38:40 +08:00
GOARCH=386 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
2018-06-20 23:00:16 +08:00
windows-amd64:
2022-03-16 12:10:13 +08:00
GOARCH=amd64 GOOS=windows GOAMD64=v3 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
2021-12-04 17:41:13 +08:00
windows-amd64-compatible:
GOARCH=amd64 GOOS=windows GOAMD64=v1 $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
2022-03-17 23:57:58 +08:00
windows-arm64:
GOARCH=arm64 GOOS=windows $(GOBUILD) -o $(BINDIR)/$(NAME)-$@.exe
2021-12-03 20:38:40 +08:00
windows-arm32v7:
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
2021-10-28 11:36:11 +08:00
vet:
2022-03-23 01:05:43 +08:00
go test ./...
2021-10-28 11:36:11 +08:00
2021-10-10 23:44:09 +08:00
lint:
2022-02-19 00:08:51 +08:00
golangci-lint run ./...
2021-10-10 23:44:09 +08:00
2018-06-17 08:18:39 +08:00
clean:
rm $(BINDIR)/*
2022-07-29 09:08:35 +08:00
CLANG ?= clang-14
CFLAGS := -O2 -g -Wall -Werror $(CFLAGS)