Skip to content
This repository was archived by the owner on Apr 3, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
VERSION=$(shell git describe --tags)
DEBUG_LDFLAGS=''
RELEASE_LDFLAGS='-s -w -X main.version=$(VERSION)'
RELEASE_LDFLAGS=-s -w -X main.version=$(VERSION)
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)"
BUILD_CMD="cd $(CMDDIR) && $(GOBUILD) -ldflags '$(RELEASE_LDFLAGS)' -o $(BUILDDIR)/$(PROGRAM) -v -tags '$(BUILD_TAGS)'"
BUILD_MUSL_CMD="cd $(CMDDIR) && CC=musl-gcc $(GOBUILD) -ldflags '$(RELEASE_LDFLAGS) -linkmode external -extldflags \"-static\" ' -o $(BUILDDIR)/$(PROGRAM) -v -tags '$(BUILD_TAGS)'"
XBUILD_CMD="cd $(BUILDDIR) && $(XGOCMD) -ldflags '$(RELEASE_LDFLAGS)' -tags '$(BUILD_TAGS)' --targets=*/* $(CMDDIR)"

all: build

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

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


xbuild:
mkdir -p $(BUILDDIR)
eval $(XBUILD_CMD)
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ The following projects are using go-tun2socks:

- https://github.com/mellow-io/mellow
- https://github.com/eycorsican/kitsunebi-android

-------
## build for musl
This build target depends on musl-gcc which can find in system path

You can build for musl system by using this command
```bash
make build_musl
```