summaryrefslogtreecommitdiffhomepage
path: root/app/tools/libwg-go/Makefile
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-03 04:47:11 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-03 05:43:42 +0100
commit49cc63467812ed9946f4a98eb73658f2ce0b2aac (patch)
treeb6e1f54465e57ae0161fcd61a701d41c18902b09 /app/tools/libwg-go/Makefile
parentc93e81c632d2be7faa53ad2803a61444710ae962 (diff)
libwg-go: don't use submodule
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/tools/libwg-go/Makefile')
-rw-r--r--app/tools/libwg-go/Makefile26
1 files changed, 5 insertions, 21 deletions
diff --git a/app/tools/libwg-go/Makefile b/app/tools/libwg-go/Makefile
index d07b313f..a72be5be 100644
--- a/app/tools/libwg-go/Makefile
+++ b/app/tools/libwg-go/Makefile
@@ -2,9 +2,6 @@
#
# Copyright © 2017-2019 WireGuard LLC. All Rights Reserved.
-UPSTREAM_FILES := $(filter-out %/main.go %/queueconstants.go,$(wildcard ../wireguard-go/*/*.go) $(wildcard ../wireguard-go/*.go)) ../wireguard-go/go.mod ../wireguard-go/go.sum
-DOWNSTREAM_FILES := $(wildcard src/*.go) $(wildcard src/*.c) $(wildcard src/*/*.go)
-
BUILDDIR ?= $(CURDIR)/build
DESTDIR ?= $(CURDIR)/out
@@ -43,23 +40,10 @@ $(GOROOT)/bin/go:
curl "$(GOBUILDTARBALL)" | tar -C "$(GOROOT)" --strip-components=1 -xzf - || { rm -rf "$(GOROOT)"; exit 1; }
patch -p1 -f -N -r- -d "$(GOROOT)" < goruntime-boottime-over-monotonic.diff || { rm -rf "$(GOROOT)"; exit 1; }
-$(shell test "$$(cat .gobuildversion 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.so")
-
-define copy-src-to-build
-$(subst $(1),$(BUILDDIR)/,$(2)): $(2)
- @mkdir -vp "$$(dir $$@)"
- @cp -vp "$$<" "$$@"
-$(BUILDDIR)/.prepared: $(subst $(1),$(BUILDDIR)/,$(2))
-endef
+$(shell test "$$(cat $(BUILDDIR)/.gobuildversion 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.so")
-$(foreach FILE,$(UPSTREAM_FILES),$(eval $(call copy-src-to-build,../wireguard-go/,$(FILE))))
-$(foreach FILE,$(DOWNSTREAM_FILES),$(eval $(call copy-src-to-build,src/,$(FILE))))
-
-$(BUILDDIR)/.prepared: $(GOROOT)/bin/go
- cd "$(BUILDDIR)" && go get || { chmod -fR +w "$(GOPATH)/pkg/mod"; rm -rf "$(GOPATH)/pkg/mod"; exit 1; }
+$(DESTDIR)/libwg-go.so: $(GOROOT)/bin/go
+ go get -tags linux || { chmod -fR +w "$(GOPATH)/pkg/mod"; rm -rf "$(GOPATH)/pkg/mod"; exit 1; }
chmod -fR +w "$(GOPATH)/pkg/mod"
- touch "$@"
-
-$(DESTDIR)/libwg-go.so: $(BUILDDIR)/.prepared
- cd "$(BUILDDIR)" && go build -ldflags="-X main.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -o "$@" -buildmode c-shared
- go version > .gobuildversion
+ go build -tags linux -ldflags="-X main.socketDirectory=/data/data/$(ANDROID_PACKAGE_NAME)/cache/wireguard" -v -o "$@" -buildmode c-shared
+ go version > $(BUILDDIR)/.gobuildversion