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

Commit ad9f1c3

Browse files
committed
add musl build target
1 parent 2022cd7 commit ad9f1c3

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,27 @@ GOBUILD=$(GOCMD) build
44
GOCLEAN=$(GOCMD) clean
55
VERSION=$(shell git describe --tags)
66
DEBUG_LDFLAGS=''
7-
RELEASE_LDFLAGS='-s -w -X main.version=$(VERSION)'
7+
RELEASE_LDFLAGS=-s -w -X main.version=$(VERSION)
88
BUILD_TAGS?=socks
99
BUILDDIR=$(shell pwd)/build
1010
CMDDIR=$(shell pwd)/cmd/tun2socks
1111
PROGRAM=tun2socks
1212

13-
BUILD_CMD="cd $(CMDDIR) && $(GOBUILD) -ldflags $(RELEASE_LDFLAGS) -o $(BUILDDIR)/$(PROGRAM) -v -tags '$(BUILD_TAGS)'"
14-
XBUILD_CMD="cd $(BUILDDIR) && $(XGOCMD) -ldflags $(RELEASE_LDFLAGS) -tags '$(BUILD_TAGS)' --targets=*/* $(CMDDIR)"
13+
BUILD_CMD="cd $(CMDDIR) && $(GOBUILD) -ldflags '$(RELEASE_LDFLAGS)' -o $(BUILDDIR)/$(PROGRAM) -v -tags '$(BUILD_TAGS)'"
14+
BUILD_MUSL_CMD="cd $(CMDDIR) && CC=musl-gcc $(GOBUILD) -ldflags '$(RELEASE_LDFLAGS) -linkmode external -extldflags \"-static\" ' -o $(BUILDDIR)/$(PROGRAM) -v -tags '$(BUILD_TAGS)'"
15+
XBUILD_CMD="cd $(BUILDDIR) && $(XGOCMD) -ldflags '$(RELEASE_LDFLAGS)' -tags '$(BUILD_TAGS)' --targets=*/* $(CMDDIR)"
1516

1617
all: build
1718

1819
build:
1920
mkdir -p $(BUILDDIR)
2021
eval $(BUILD_CMD)
2122

23+
build_musl:
24+
mkdir -p $(BUILDDIR)
25+
eval $(BUILD_CMD)
26+
27+
2228
xbuild:
2329
mkdir -p $(BUILDDIR)
2430
eval $(XBUILD_CMD)

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,13 @@ The following projects are using go-tun2socks:
2020

2121
- https://github.com/mellow-io/mellow
2222
- https://github.com/eycorsican/kitsunebi-android
23+
24+
-------
25+
## build for musl
26+
This build target depends on musl-gcc which can find in system path
27+
28+
You can build for musl system by using this command
29+
```bash
30+
make build_musl
31+
```
32+

0 commit comments

Comments
 (0)