2018-06-09 01:14:34 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
#
|
|
|
|
# Copyright (C) 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
|
|
|
|
|
|
|
|
FILES := $(filter-out %/main.go,$(wildcard ../wireguard-go/*/*.go) $(wildcard ../wireguard-go/*.go))
|
|
|
|
|
|
|
|
# CLANG_FLAGS := --target=$(ANDROID_LLVM_TRIPLE) --gcc-toolchain=$(ANDROID_TOOLCHAIN_ROOT) --sysroot=$(ANDROID_SYSROOT)
|
|
|
|
# export CGO_CFLAGS := $(CLANG_FLAGS) $(CFLAGS)
|
|
|
|
# export CGO_LDFLAGS := $(CLANG_FLAGS) $(LDFLAGS)
|
|
|
|
# export CC := $(ANDROID_C_COMPILER)
|
|
|
|
# export GOARCH := $(NDK_GO_ARCH_MAP_$(ANDROID_ARCH_NAME))
|
|
|
|
export GOOS := darwin
|
|
|
|
export CGO_ENABLED := 1
|
|
|
|
|
|
|
|
default: example
|
|
|
|
|
2018-06-12 22:35:15 +00:00
|
|
|
libwg-go.a: $(FILES) src/git.zx2c4.com/wireguard-go/api-ios.go src/git.zx2c4.com/wireguard-go/tun/tun_ios.go
|
2018-06-09 01:14:34 +00:00
|
|
|
find . -name '*.go' -type l -delete
|
|
|
|
find . -type d -empty -delete
|
|
|
|
mkdir -p $(subst ../wireguard-go/,./src/git.zx2c4.com/wireguard-go/,$(dir $(FILES)))
|
2018-06-12 03:19:21 +00:00
|
|
|
$(foreach FILE,$(FILES),ln -sf $(abspath $(FILE)) $(subst ../wireguard-go/,./src/git.zx2c4.com/wireguard-go/,$(dir $(FILE)))$(notdir $(FILE));)
|
2018-06-09 01:14:34 +00:00
|
|
|
GOPATH=$(PWD) go get -v -d git.zx2c4.com/wireguard-go
|
2018-06-12 22:35:15 +00:00
|
|
|
GOPATH=$(PWD) go build -tags ios -v -o libwg-go.a -buildmode c-archive git.zx2c4.com/wireguard-go
|
2018-06-09 01:14:34 +00:00
|
|
|
@rm -f libwg-go.h
|
|
|
|
|
2018-06-12 22:35:15 +00:00
|
|
|
example: example.c libwg-go.a
|
2018-06-09 01:14:34 +00:00
|
|
|
$(CC) -L. -lwg-go -o example example.c
|
|
|
|
|
|
|
|
clean:
|
2018-06-12 22:35:15 +00:00
|
|
|
rm -f libwg-go.a test
|
2018-06-09 01:14:34 +00:00
|
|
|
|
|
|
|
.PHONY: clean default
|