Skip to content
This repository has been archived by the owner on Apr 3, 2021. It is now read-only.

Commit

Permalink
Static build for linux only
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost committed Aug 9, 2020
1 parent 7ba5098 commit 0ced89a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,32 @@ GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
VERSION=$(shell git describe --tags)
DEBUG_LDFLAGS=''
RELEASE_LDFLAGS='-s -w -X main.version=$(VERSION) -extldflags "-static"'
RELEASE_LDFLAGS='-s -w -X main.version=$(VERSION)'
STATIC_RELEASE_LDFLAGS='-s -w -X main.version=$(VERSION) -extldflags "-static"'
BUILD_TAGS?=socks
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)'"
XBUILD_CMD="cd $(BUILDDIR) && $(XGOCMD) -ldflags $(RELEASE_LDFLAGS) -tags '$(BUILD_TAGS)' --targets=*/* $(CMDDIR)"
XBUILD_LINUX_CMD="cd $(BUILDDIR) && $(XGOCMD) -ldflags $(STATIC_RELEASE_LDFLAGS) -tags '$(BUILD_TAGS)' --targets=linux/* $(CMDDIR)"
XBUILD_OTHERS_CMD="cd $(BUILDDIR) && $(XGOCMD) -ldflags $(RELEASE_LDFLAGS) -tags '$(BUILD_TAGS)' --targets=darwin/*,windows/*,android/*,ios/* $(CMDDIR)"

all: build

build:
mkdir -p $(BUILDDIR)
eval $(BUILD_CMD)

xbuild:
xbuild_linux:
mkdir -p $(BUILDDIR)
eval $(XBUILD_CMD)
eval $(XBUILD_LINUX_CMD)

xbuild_others:
mkdir -p $(BUILDDIR)
eval $(XBUILD_OTHERS_CMD)

xbuild: xbuild_linux xbuild_others

travisbuild: xbuild

Expand Down

0 comments on commit 0ced89a

Please sign in to comment.