|
@ -1,17 +1,18 @@ |
|
|
BINARY = tun2socks |
|
|
BINARY := tun2socks |
|
|
OUTPUT = bin |
|
|
MODULE := github.com/xjasonlyu/tun2socks |
|
|
|
|
|
|
|
|
BUILD_FLAGS = -v |
|
|
BUILD_DIR := build |
|
|
BUILD_TAGS = |
|
|
BUILD_TAGS := |
|
|
BUILD_COMMIT = $(shell git describe --dirty --always) |
|
|
BUILD_FLAGS := -v |
|
|
BUILD_VERSION = $(shell git describe --abbrev=0 --tags HEAD) |
|
|
BUILD_COMMIT := $(shell git describe --dirty --always) |
|
|
|
|
|
BUILD_VERSION := $(shell git describe --abbrev=0 --tags HEAD) |
|
|
|
|
|
|
|
|
CGO_ENABLED = 0 |
|
|
CGO_ENABLED := 0 |
|
|
GO111MODULE = on |
|
|
GO111MODULE := on |
|
|
|
|
|
|
|
|
LDFLAGS += -w -s -buildid= |
|
|
LDFLAGS += -w -s -buildid= |
|
|
LDFLAGS += -X "github.com/xjasonlyu/tun2socks/constant.Version=$(BUILD_VERSION)" |
|
|
LDFLAGS += -X "$(MODULE)/constant.Version=$(BUILD_VERSION)" |
|
|
LDFLAGS += -X "github.com/xjasonlyu/tun2socks/constant.GitCommit=$(BUILD_COMMIT)" |
|
|
LDFLAGS += -X "$(MODULE)/constant.GitCommit=$(BUILD_COMMIT)" |
|
|
|
|
|
|
|
|
GO_BUILD = GO111MODULE=$(GO111MODULE) CGO_ENABLED=$(CGO_ENABLED) \
|
|
|
GO_BUILD = GO111MODULE=$(GO111MODULE) CGO_ENABLED=$(CGO_ENABLED) \
|
|
|
go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' -trimpath |
|
|
go build $(BUILD_FLAGS) -ldflags '$(LDFLAGS)' -tags '$(BUILD_TAGS)' -trimpath |
|
@ -24,52 +25,45 @@ PLATFORM_LIST = \ |
|
|
linux-arm64 \
|
|
|
linux-arm64 \
|
|
|
openbsd-amd64 \
|
|
|
openbsd-amd64 \
|
|
|
openbsd-arm64 \
|
|
|
openbsd-arm64 \
|
|
|
|
|
|
|
|
|
WINDOWS_ARCH_LIST = \
|
|
|
|
|
|
windows-amd64 \
|
|
|
windows-amd64 \
|
|
|
|
|
|
|
|
|
all: linux-amd64 darwin-amd64 windows-amd64 |
|
|
all: linux-amd64 darwin-amd64 windows-amd64 |
|
|
|
|
|
|
|
|
tun2socks: |
|
|
tun2socks: |
|
|
$(GO_BUILD) -o $(OUTPUT)/$(BINARY) |
|
|
$(GO_BUILD) -o $(BUILD_DIR)/$(BINARY) |
|
|
|
|
|
|
|
|
darwin-amd64: |
|
|
darwin-amd64: |
|
|
GOARCH=amd64 GOOS=darwin $(GO_BUILD) -o $(OUTPUT)/$(BINARY)-$@ |
|
|
GOARCH=amd64 GOOS=darwin $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@ |
|
|
|
|
|
|
|
|
freebsd-amd64: |
|
|
freebsd-amd64: |
|
|
GOARCH=amd64 GOOS=freebsd $(GO_BUILD) -o $(OUTPUT)/$(BINARY)-$@ |
|
|
GOARCH=amd64 GOOS=freebsd $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@ |
|
|
|
|
|
|
|
|
freebsd-arm64: |
|
|
freebsd-arm64: |
|
|
GOARCH=arm64 GOOS=freebsd $(GO_BUILD) -o $(OUTPUT)/$(BINARY)-$@ |
|
|
GOARCH=arm64 GOOS=freebsd $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@ |
|
|
|
|
|
|
|
|
linux-amd64: |
|
|
linux-amd64: |
|
|
GOARCH=amd64 GOOS=linux $(GO_BUILD) -o $(OUTPUT)/$(BINARY)-$@ |
|
|
GOARCH=amd64 GOOS=linux $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@ |
|
|
|
|
|
|
|
|
linux-arm64: |
|
|
linux-arm64: |
|
|
GOARCH=arm64 GOOS=linux $(GO_BUILD) -o $(OUTPUT)/$(BINARY)-$@ |
|
|
GOARCH=arm64 GOOS=linux $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@ |
|
|
|
|
|
|
|
|
openbsd-amd64: |
|
|
openbsd-amd64: |
|
|
GOARCH=amd64 GOOS=openbsd $(GO_BUILD) -o $(OUTPUT)/$(BINARY)-$@ |
|
|
GOARCH=amd64 GOOS=openbsd $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@ |
|
|
|
|
|
|
|
|
openbsd-arm64: |
|
|
openbsd-arm64: |
|
|
GOARCH=arm64 GOOS=openbsd $(GO_BUILD) -o $(OUTPUT)/$(BINARY)-$@ |
|
|
GOARCH=arm64 GOOS=openbsd $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@ |
|
|
|
|
|
|
|
|
windows-amd64: |
|
|
windows-amd64: |
|
|
GOARCH=amd64 GOOS=windows $(GO_BUILD) -o $(OUTPUT)/$(BINARY)-$@.exe |
|
|
GOARCH=amd64 GOOS=windows $(GO_BUILD) -o $(BUILD_DIR)/$(BINARY)-$@.exe |
|
|
|
|
|
|
|
|
gz_releases=$(addsuffix .gz, $(PLATFORM_LIST)) |
|
|
|
|
|
zip_releases=$(addsuffix .zip, $(WINDOWS_ARCH_LIST)) |
|
|
|
|
|
|
|
|
|
|
|
$(gz_releases): %.gz : % |
|
|
zip_releases := $(addsuffix .zip, $(PLATFORM_LIST)) |
|
|
chmod +x $(OUTPUT)/$(BINARY)-$(basename $@) |
|
|
|
|
|
gzip -f -S .gz $(OUTPUT)/$(BINARY)-$(basename $@) |
|
|
|
|
|
|
|
|
|
|
|
$(zip_releases): %.zip : % |
|
|
$(zip_releases): %.zip: % |
|
|
zip -m -j $(OUTPUT)/$(BINARY)-$(basename $@).zip $(OUTPUT)/$(BINARY)-$(basename $@).exe |
|
|
@zip -m -j $(BUILD_DIR)/$(BINARY)-$(basename $@).zip $(BUILD_DIR)/$(BINARY)-$(basename $@)* |
|
|
|
|
|
|
|
|
all-arch: $(PLATFORM_LIST) $(WINDOWS_ARCH_LIST) |
|
|
all-arch: $(PLATFORM_LIST) |
|
|
|
|
|
|
|
|
releases: $(gz_releases) $(zip_releases) |
|
|
releases: $(zip_releases) |
|
|
|
|
|
|
|
|
clean: |
|
|
clean: |
|
|
rm $(OUTPUT)/* |
|
|
rm -rf $(BUILD_DIR) |
|
|