wireguard-go-bridge: use go modules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -48,39 +48,27 @@ $(GOROOT)/bin/go: .cache/$(GOBUILDTARBALL)
|
||||
mkdir -p "$(GOROOT)"
|
||||
tar -C "$(GOROOT)" --strip-components=1 -xzf - < .cache/$(GOBUILDTARBALL) || { rm -rf "$(GOROOT)"; exit 1; }
|
||||
patch -p1 -f -N -r- -d "$(GOROOT)" < goruntime-boottime-over-monotonic.diff || { rm -rf "$(GOROOT)"; exit 1; }
|
||||
touch $@
|
||||
|
||||
$(shell test "$$(cat "$(BUILDDIR)/.gobuildversion" 2>/dev/null)" = "$(GOBUILDVERSION_CURRENT)" || rm -f "$(DESTDIR)/libwg-go.a")
|
||||
|
||||
define copy-src-to-build
|
||||
$(subst $(1),$(BUILDDIR)/,$(2)): $(2)
|
||||
@mkdir -vp "$$(dir $$@)"
|
||||
@cp -vp "$$<" "$$@"
|
||||
$(BUILDDIR)/.prepared: $(subst $(1),$(BUILDDIR)/,$(2))
|
||||
endef
|
||||
|
||||
$(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)" || exit $$?; $(foreach ARCH,$(ARCHS),CGO_CFLAGS="$(CFLAGS_PREFIX) $(ARCH)" CGO_LDFLAGS="$(CFLAGS_PREFIX) $(ARCH)" GOARCH="$(GOARCH_$(ARCH))" go get -tags ios || { ret=$$?; chmod -fR +w "$(GOPATH)/pkg/mod"; rm -rf "$(GOPATH)/pkg/mod"; exit $$ret; };)
|
||||
chmod -fR +w "$(GOPATH)/pkg/mod"
|
||||
touch "$@"
|
||||
|
||||
define libwg-go-a
|
||||
$(BUILDDIR)/libwg-go-$(1).a: $(BUILDDIR)/.prepared
|
||||
cd "$(BUILDDIR)" || exit $$$$?; \
|
||||
$(BUILDDIR)/libwg-go-$(1).a: $(GOROOT)/bin/go
|
||||
CGO_CFLAGS="$(CFLAGS_PREFIX) $(ARCH)" \
|
||||
CGO_LDFLAGS="$(CFLAGS_PREFIX) $(ARCH)" \
|
||||
GOARCH="$(GOARCH_$(1))" \
|
||||
go build -tags ios -ldflags=-w -v -o "$(BUILDDIR)/libwg-go-$(1).a" -buildmode c-archive && go version > "$(BUILDDIR)/.gobuildversion"; \
|
||||
chmod -fR +w "$(GOPATH)/pkg/mod"; \
|
||||
ret=$$$$?; \
|
||||
rm -f "$(BUILDDIR)/libwg-go-$(1).h"; \
|
||||
exit $$$$ret
|
||||
endef
|
||||
$(foreach ARCH,$(ARCHS),$(eval $(call libwg-go-a,$(ARCH))))
|
||||
|
||||
$(DESTDIR)/wireguard-go-version.h: ../wireguard-go/version.go
|
||||
sed -n 's/.*WireGuardGoVersion = "\(.*\)"/#define WIREGUARD_GO_VERSION "\1"/p' "$^" > "$@"
|
||||
$(DESTDIR)/wireguard-go-version.h: go.mod $(GOROOT)/bin/go
|
||||
go get -d -tags ios; chmod -fR +w "$(GOPATH)/pkg/mod"
|
||||
wggo="$(GOPATH)/pkg/mod/$$(sed -n 's/.*\(golang\.zx2c4\.com\/wireguard\) \(.*\)$$/\1@\2/p' go.mod)"; \
|
||||
sed -n 's/.*WireGuardGoVersion = "\(.*\)"/#define WIREGUARD_GO_VERSION "\1"/p' "$$wggo/device/version.go" > "$@"
|
||||
|
||||
$(DESTDIR)/libwg-go.a: $(foreach ARCH,$(ARCHS),$(BUILDDIR)/libwg-go-$(ARCH).a)
|
||||
@mkdir -vp "$(DESTDIR)"
|
||||
|
||||
Reference in New Issue
Block a user