mirror of
https://github.com/AuxXxilium/synology-wireguard.git
synced 2025-02-21 17:50:00 +07:00
Fixed build errors and made the resulting binary use compatibility mode for memneq implementation
This commit is contained in:
parent
f4876efbc3
commit
902ddaa491
35
Makefile
35
Makefile
@ -1,44 +1,57 @@
|
||||
WIREGUARD_VERSION ?= 0.0.20190227
|
||||
LIBMNL_VERSION ?= 1.0.4
|
||||
|
||||
LIBMNL_TAR = libmnl-$(LIBMNL_VERSION).tar.bz2
|
||||
LIBMNL_DIR = libmnl-$(LIBMNL_VERSION)
|
||||
LIBMNL_TAR := libmnl-$(LIBMNL_VERSION).tar.bz2
|
||||
LIBMNL_DIR := libmnl-$(LIBMNL_VERSION)
|
||||
|
||||
WIREGUARD_TAR = WireGuard-$(WIREGUARD_VERSION).tar.xz
|
||||
WIREGUARD_DIR = WireGuard-$(WIREGUARD_VERSION)
|
||||
WIREGUARD_TAR := WireGuard-$(WIREGUARD_VERSION).tar.xz
|
||||
WIREGUARD_DIR := WireGuard-$(WIREGUARD_VERSION)
|
||||
|
||||
WG_TARGET = $(WIREGUARD_DIR)/src/tools/wg
|
||||
WG_QUICK_TARGET = $(WIREGUARD_DIR)/wg-quick
|
||||
WG_MODULE_TARGET = $(WIREGUARD_DIR)/src/wireguard.ko
|
||||
WG_TARGET := $(WIREGUARD_DIR)/src/tools/wg
|
||||
WG_QUICK_TARGET := $(WIREGUARD_DIR)/wg-quick
|
||||
WG_MODULE_TARGET := $(WIREGUARD_DIR)/src/wireguard.ko
|
||||
|
||||
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
GCC := $(CROSS_COMPILE)gcc
|
||||
|
||||
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
all: $(WG_TARGET) $(WG_QUICK_TARGET) $(WG_MODULE_TARGET)
|
||||
|
||||
# Download libmnl source tarball
|
||||
$(LIBMNL_TAR):
|
||||
wget https://netfilter.org/projects/libmnl/files/$(LIBMNL_TAR)
|
||||
|
||||
# Prepare libmnl for building
|
||||
$(LIBMNL_DIR)/Makefile: $(LIBMNL_TAR)
|
||||
tar -xf $(LIBMNL_TAR)
|
||||
(cd $(LIBMNL_DIR) && ./configure --host=x86_64-unknown-linux-gnu --enable-static --target=arm-unknown-linux-gnueabi CC=$(CROSS_COMPILE)-gcc)
|
||||
(cd $(LIBMNL_DIR) && ./configure --host=x86_64-unknown-linux-gnu --enable-static --target=arm-unknown-linux-gnueabi CC=$(GCC))
|
||||
|
||||
# Compile libmnl static lib
|
||||
$(LIBMNL_DIR)/src/.libs/libmnl.a: $(LIBMNL_DIR)/Makefile
|
||||
make -C $(LIBMNL_DIR)
|
||||
|
||||
# Download WireGuard source tarball
|
||||
$(WIREGUARD_TAR):
|
||||
wget https://git.zx2c4.com/WireGuard/snapshot/$(WIREGUARD_TAR)
|
||||
|
||||
# Unpack WireGuard source tarball and patch the compatibility layer to always
|
||||
# use memneq implementation as it doesn't appear to be included on the D218j.
|
||||
$(WIREGUARD_DIR)/src/Makefile: $(WIREGUARD_TAR)
|
||||
tar -xf $(WIREGUARD_TAR)
|
||||
echo 'ccflags-y += -include $(kbuild-dir)/compat/memneq/include.h' >> $(WIREGUARD_DIR)/src/compat/Kbuild.include
|
||||
echo 'wireguard-y += compat/memneq/memneq.o' >> $(WIREGUARD_DIR)/src/compat/Kbuild.include
|
||||
|
||||
# Build the wg command line tool
|
||||
$(WG_TARGET): $(LIBMNL_DIR)/src/.libs/libmnl.a $(WIREGUARD_DIR)/src/Makefile
|
||||
CFLAGS=-I$(ROOT_DIR)/$(LIBMNL_DIR)/include LDFLAGS=-L$(ROOT_DIR)/$(LIBMNL_DIR)/src/.libs make -C $(WIREGUARD_DIR)/src/tools CC=$(CROSS_COMPILE)-gcc
|
||||
CFLAGS=-I$(ROOT_DIR)/$(LIBMNL_DIR)/include LDFLAGS=-L$(ROOT_DIR)/$(LIBMNL_DIR)/src/.libs make -C $(WIREGUARD_DIR)/src/tools CC=$(GCC)
|
||||
|
||||
# Choose the correct wg-quick implementation
|
||||
$(WG_QUICK_TARGET): $(WIREGUARD_DIR)/src/Makefile
|
||||
cp $(WIREGUARD_DIR)/src/tools/wg-quick/linux.bash $(WG_QUICK_TARGET)
|
||||
|
||||
# Build wireguard.ko kernel module
|
||||
$(WG_MODULE_TARGET):
|
||||
make -C $(WIREGUARD_DIR)/src module ARCH=arm KERNELDIR=$(KSRC) EXTRA_CFLAGS="-DCONFIG_SYNO_BACKPORT_ARM_CRYPTO=1"
|
||||
make -C $(WIREGUARD_DIR)/src module ARCH=arm KERNELDIR=$(KSRC)
|
||||
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)/wireguard/
|
||||
|
13
README.rst
13
README.rst
@ -49,14 +49,23 @@ you can figure out how the next command should look like. In my case it's:
|
||||
.. code-block:: bash
|
||||
|
||||
pkgscripts-ng/EnvDeploy -p armada38x -v 6.2
|
||||
cp /etc/ssl/certs/ca-certificates.crt /build_env/*/etc/ssl/certs/
|
||||
|
||||
Now we can build an SPK package:
|
||||
The second command is very important, or the package build will fail on SSL
|
||||
errors. Now we can build an SPK package:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pkgscripts-ng/PkgCreate.py -p armada38x -v 6.2 -S --build-opt=-J --print-log -c WireGuard
|
||||
|
||||
There should now be an SPK in ``/result_spk``
|
||||
There should now be an SPK in ``/result_spk``. You can now exit the docker
|
||||
container and extract the SPKs:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo docker cp synobuild:/result_spk/WireGuard-0.0.20190227/WireGuard-armada38x-0.0.20190227.spk .
|
||||
sudo docker cp synobuild:/result_spk/WireGuard-0.0.20190227/WireGuard-armada38x-0.0.20190227_debug.spk .
|
||||
|
||||
|
||||
Credits
|
||||
-------
|
||||
|
Loading…
Reference in New Issue
Block a user