@@ -8,6 +8,7 @@ PLATFORM_NAME ?= macosx
8
8
SDKROOT ?= $(shell xcrun --sdk $(PLATFORM_NAME ) --show-sdk-path)
9
9
CONFIGURATION_BUILD_DIR ?= $(CURDIR ) /out
10
10
CONFIGURATION_TEMP_DIR ?= $(CURDIR ) /.tmp
11
+ CACHE_ROOT ?= $(CURDIR ) /.cache
11
12
12
13
export PATH := $(PATH ) :/usr/local/bin:/opt/homebrew/bin
13
14
export CC ?= clang
@@ -21,29 +22,36 @@ GOARCH_x86_64 := amd64
21
22
GOOS_macosx := darwin
22
23
GOOS_iphoneos := ios
23
24
24
- GO_VERSION := 1.20.2
25
+ GO_VERSION := 1.20.3
25
26
GO_PLATFORM := $(shell uname -s | tr '[:upper:]' '[:lower:]') -$(GOARCH_$(shell uname -m) )
26
27
GO_TARBALL := go$(GO_VERSION ) .$(GO_PLATFORM ) .tar.gz
27
- GO_HASH_darwin-amd64 := c93b8ced9517d07e1cd4c362c6e2d5242cb139e29b417a328fbf19aded08764c
28
- GO_HASH_darwin-arm64 := 7343c87f19e79c0063532e82e1c4d6f42175a32d99f7a4d15e658e88bf97f885
28
+ GO_HASH_darwin-amd64 := c1e1161d6d859deb576e6cfabeb40e3d042ceb1c6f444f617c3c9d76269c3565
29
+ GO_HASH_darwin-arm64 := 86b0ed0f2b2df50fa8036eea875d1cf2d76cefdacf247c44639a1464b7e36b95
30
+ GO_ROOT := $(BUILDDIR ) /go-$(GO_VERSION )
31
+
32
+
33
+ UNAME := $(shell uname -m)
34
+ ifeq ($(UNAME ) , $(GOARCH_arm64 ) )
35
+ GOOS_iphonesimulator := ios
36
+ endif
29
37
30
38
build : $(DESTDIR ) /libwg-go.a
31
39
version-header : $(DESTDIR ) /wireguard-go-version.h
32
40
33
- $(BUILDDIR ) /$(GO_TARBALL ) :
34
- mkdir -p " $( @D ) "
41
+ $(CACHE_ROOT ) /$(GO_TARBALL ) :
42
+ mkdir -p " $( dir $@ ) "
35
43
flock " $@ .lock" -c ' \
36
44
[ -f " $@ " ] && exit 0; \
37
- curl -o " $@ .tmp" " https://dl.google.com/go /$( GO_TARBALL) " && \
38
- echo " $( GO_HASH_$( GO_PLATFORM) ) $@ .tmp" | sha256sum -c && \
45
+ wget -O " $@ .tmp" " https://go.dev/dl /$( GO_TARBALL) " && \
46
+ echo " $( GO_HASH_$( GO_PLATFORM) ) $@ .tmp" | sha256sum -c && \
39
47
mv " $@ .tmp" " $@ " '
40
48
41
- $( BUILDDIR ) /go- $( GO_VERSION ) / .prepared : $(BUILDDIR ) /$(GO_TARBALL )
42
- mkdir -p " $( @D ) "
49
+ $( GO_ROOT ) / .prepared : $(CACHE_ROOT ) /$(GO_TARBALL )
50
+ mkdir -p " $( dir $@ ) "
43
51
flock " $@ .lock" -c ' \
44
52
[ -f " $@ " ] && exit 0; \
45
- tar -C " $( @D ) " --strip-components=1 -xzf " $^" && \
46
- patch -p1 -f -N -r- -d " $( @D ) " < goruntime-boottime-over-monotonic.diff && \
53
+ tar -C " $( dir $@ ) " --strip-components=1 -xzf " $^" && \
54
+ patch -p1 -f -N -r- -d " $( dir $@ ) " < goruntime-boottime-over-monotonic.diff && \
47
55
touch " $@ " '
48
56
49
57
define libwg-go-a
@@ -52,16 +60,16 @@ $(BUILDDIR)/libwg-go-$(1).a: export CGO_CFLAGS := $(CFLAGS_PREFIX) $(ARCH)
52
60
$(BUILDDIR ) /libwg-go-$(1 ) .a: export CGO_LDFLAGS := $(CFLAGS_PREFIX ) $(ARCH )
53
61
$(BUILDDIR ) /libwg-go-$(1 ) .a: export GOOS := $(GOOS_$(PLATFORM_NAME ) )
54
62
$(BUILDDIR ) /libwg-go-$(1 ) .a: export GOARCH := $(GOARCH_$(1 ) )
55
- $(BUILDDIR ) /libwg-go-$(1 ) .a: $(BUILDDIR ) /go- $( GO_VERSION ) /.prepared go.mod
63
+ $(BUILDDIR ) /libwg-go-$(1 ) .a: $(GO_ROOT ) /.prepared go.mod
56
64
go build -ldflags=-w -trimpath -v -o "$(BUILDDIR ) /libwg-go-$(1 ) .a" -buildmode c-archive
57
65
$(RM ) "$(BUILDDIR ) /libwg-go-$(1 ) .h"
58
66
endef
59
67
$(foreach ARCH,$(ARCHS),$(eval $(call libwg-go-a,$(ARCH))))
60
68
61
- $(DESTDIR ) /wireguard-go-version.h : $( BUILDDIR ) /go- $( GO_VERSION ) /.prepared go.mod
69
+ $(DESTDIR ) /wireguard-go-version.h : go.mod $( GO_ROOT ) /.prepared
62
70
sed -E -n ' s/.*golang\.zx2c4\.com\/wireguard +v[0-9.]+-[0-9]+-([0-9a-f]{8})[0-9a-f]{4}.*/#define WIREGUARD_GO_VERSION "\1"/p' " $<" > " $@ "
63
71
64
- $(DESTDIR ) /llibwg -go.a : export PATH := $(BUILDDIR ) /go- $( GO_VERSION ) /bin/:$(PATH )
72
+ $(DESTDIR ) /libwg -go.so : export PATH := $(GO_ROOT ) /bin/:$(PATH )
65
73
$(DESTDIR ) /libwg-go.a : $(foreach ARCH,$(ARCHS ) ,$(BUILDDIR ) /libwg-go-$(ARCH ) .a)
66
74
@mkdir -vp " $( DESTDIR) "
67
75
$(LIPO ) -create -output " $@ " $^
0 commit comments