Jason
5 years ago
1 changed files with 10 additions and 41 deletions
@ -1,50 +1,19 @@ |
|||
GOCMD=go |
|||
XGOCMD=xgo |
|||
GOBUILD=$(GOCMD) build |
|||
GOCLEAN=$(GOCMD) clean |
|||
VERSION=$(shell git describe --tags) |
|||
DEBUG_LDFLAGS='' |
|||
RELEASE_LDFLAGS='-s -w -X main.version=$(VERSION)' |
|||
BUILD_TAGS?=socks fakedns d stats |
|||
DEBUG_BUILD_TAGS=$(BUILD_TAGS) debug |
|||
NAME=tun2socks |
|||
BUILDDIR=$(shell pwd)/build |
|||
CMDDIR=$(shell pwd)/cmd/tun2socks |
|||
PROGRAM=tun2socks |
|||
|
|||
BUILD_CMD="cd $(CMDDIR) && $(GOBUILD) -ldflags $(RELEASE_LDFLAGS) -o $(BUILDDIR)/$(PROGRAM) -v -tags '$(BUILD_TAGS)'" |
|||
DBUILD_CMD="cd $(CMDDIR) && $(GOBUILD) -race -ldflags $(DEBUG_LDFLAGS) -o $(BUILDDIR)/$(PROGRAM) -v -tags '$(DEBUG_BUILD_TAGS)'" |
|||
XBUILD_CMD="cd $(BUILDDIR) && $(XGOCMD) -ldflags $(RELEASE_LDFLAGS) -tags '$(BUILD_TAGS)' --targets=*/* $(CMDDIR)" |
|||
RELEASE_CMD="cd $(BUILDDIR) && $(XGOCMD) -ldflags $(RELEASE_LDFLAGS) -tags '$(BUILD_TAGS)' --targets=linux/amd64,linux/arm64,linux/386,linux/mips,linux/mipsle,linux/mips64,linux/mips64le,windows/*,darwin/* $(CMDDIR)" |
|||
WINDOWS_CMD="cd $(BUILDDIR) && $(XGOCMD) -ldflags $(RELEASE_LDFLAGS) -tags '$(BUILD_TAGS)' --targets=windows/amd64 $(CMDDIR)" |
|||
VERSION=$(shell git describe --tags || echo "unknown version") |
|||
BUILDTIME=$(shell date -u) |
|||
BUILD_TAGS='socks fakedns d stats' |
|||
BUILD_LDFLAGS='-s -w -X "main.version=$(VERSION)" -X "main.buildTime=$(BUILDTIME)"' |
|||
GOBUILD=go build -ldflags $(BUILD_LDFLAGS) -v -tags $(BUILD_TAGS) |
|||
|
|||
all: build |
|||
|
|||
build: |
|||
mkdir -p $(BUILDDIR) |
|||
eval $(BUILD_CMD) |
|||
|
|||
dbuild: |
|||
mkdir -p $(BUILDDIR) |
|||
eval $(DBUILD_CMD) |
|||
|
|||
windows: |
|||
mkdir -p $(BUILDDIR) |
|||
eval $(WINDOWS_CMD) |
|||
cd $(CMDDIR) && $(GOBUILD) -o $(BUILDDIR)/$(NAME) |
|||
|
|||
xbuild: |
|||
mkdir -p $(BUILDDIR) |
|||
eval $(XBUILD_CMD) |
|||
|
|||
release: |
|||
mkdir -p $(BUILDDIR) |
|||
eval $(RELEASE_CMD) |
|||
|
|||
travisbuild: xbuild |
|||
debug: |
|||
cd $(CMDDIR) && $(GOBUILD) -race -o $(BUILDDIR)/$(NAME) |
|||
|
|||
clean: |
|||
rm -rf $(BUILDDIR) |
|||
|
|||
cleancache: |
|||
# go build cache may need to cleanup if changing C source code |
|||
$(GOCLEAN) -cache |
|||
rm -rf $(BUILDDIR) |
|||
rm -rf $(BUILDDIR) |
Loading…
Reference in new issue