diff --git a/repos/dde_linux/lib/mk/spec/arm_v8/wireguard.mk b/repos/dde_linux/lib/mk/spec/arm_v8/wireguard.mk index 46ce1d80c6..58bc4afd07 100644 --- a/repos/dde_linux/lib/mk/spec/arm_v8/wireguard.mk +++ b/repos/dde_linux/lib/mk/spec/arm_v8/wireguard.mk @@ -1,3 +1,25 @@ -INC_DIR += $(REP_DIR)/src/include/spec/arm_v8 +# +# For documentation see $(REP_DIR)/lib/mk/wireguard.inc +# + +PRG_TOP_DIR := $(REP_DIR)/src/app/wireguard +PRG_DIR := $(PRG_TOP_DIR)/spec/arm_v8 + +DDE_LINUX_DIR := $(subst /src/include/lx_kit,,$(call select_from_repositories,src/include/lx_kit)) + +SRC_C += arch/arm64/kernel/smp.c +SRC_C += arch/arm64/kernel/cpufeature.c + +vpath arch/arm64/kernel/cpufeature.c $(PRG_TOP_DIR)/lx_emul/shadow +vpath arch/arm64/kernel/smp.c $(DDE_LINUX_DIR)/src/lib/lx_emul/shadow + +SRC_S += arch/arm64/crypto/poly1305-core.S + +arch/arm64/crypto/poly1305-core.S: + $(MSG_CONVERT)$@ + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)perl $(LX_SRC_DIR)/arch/arm64/crypto/poly1305-armv8.pl > $@ + +CC_OPT_arch/arm64/crypto/poly1305-core += -Dpoly1305_init=poly1305_init_arm64 include $(REP_DIR)/lib/mk/wireguard.inc diff --git a/repos/dde_linux/lib/mk/spec/arm_v8/wireguard_lx_inc_dirs.mk b/repos/dde_linux/lib/mk/spec/arm_v8/wireguard_lx_inc_dirs.mk deleted file mode 100644 index 25152c40da..0000000000 --- a/repos/dde_linux/lib/mk/spec/arm_v8/wireguard_lx_inc_dirs.mk +++ /dev/null @@ -1,26 +0,0 @@ -# -# For documentation see $(REP_DIR)/lib/mk/wireguard_lx_inc_dirs.inc . -# - -PRG_DIR := $(REP_DIR)/src/app/wireguard/spec/arm_v8 -GEN_PRG_DIR := $(PRG_DIR)/../.. - -DDE_LINUX_DIR := $(subst /src/include/lx_kit,,$(call select_from_repositories,src/include/lx_kit)) - -SRC_C += arch/arm64/kernel/smp.c -SRC_C += arch/arm64/kernel/cpufeature.c - -vpath arch/arm64/kernel/cpufeature.c $(GEN_PRG_DIR)/lx_emul/shadow -vpath arch/arm64/kernel/smp.c $(DDE_LINUX_DIR)/src/lib/lx_emul/shadow - -SRC_S += arch/arm64/crypto/poly1305-core.S - -arch/arm64/crypto/poly1305-core.S: - $(MSG_CONVERT)$@ - $(VERBOSE)mkdir -p $(dir $@) - $(VERBOSE)perl $(LX_SRC_DIR)/arch/arm64/crypto/poly1305-armv8.pl > $@ - -CC_OPT_arch/arm64/crypto/poly1305-core += -Dpoly1305_init=poly1305_init_arm64 - -include $(REP_DIR)/lib/mk/wireguard_lx_inc_dirs.inc - diff --git a/repos/dde_linux/lib/mk/spec/x86_64/wireguard.mk b/repos/dde_linux/lib/mk/spec/x86_64/wireguard.mk index dc08e92cca..d1ade89275 100644 --- a/repos/dde_linux/lib/mk/spec/x86_64/wireguard.mk +++ b/repos/dde_linux/lib/mk/spec/x86_64/wireguard.mk @@ -1,3 +1,15 @@ -INC_DIR += $(REP_DIR)/src/include/spec/x86_64 +# +# For documentation see $(REP_DIR)/lib/mk/wireguard.inc +# + +PRG_TOP_DIR := $(REP_DIR)/src/app/wireguard +PRG_DIR := $(PRG_TOP_DIR)/spec/x86_64 + +SRC_S += arch/x86/crypto/poly1305-x86_64-cryptogams.S + +arch/x86/crypto/poly1305-x86_64-cryptogams.S: + $(MSG_CONVERT)$@ + $(VERBOSE)mkdir -p $(dir $@) + $(VERBOSE)perl $(LX_SRC_DIR)/arch/x86/crypto/poly1305-x86_64-cryptogams.pl > $@ include $(REP_DIR)/lib/mk/wireguard.inc diff --git a/repos/dde_linux/lib/mk/spec/x86_64/wireguard_lx_inc_dirs.mk b/repos/dde_linux/lib/mk/spec/x86_64/wireguard_lx_inc_dirs.mk deleted file mode 100644 index b118e8d641..0000000000 --- a/repos/dde_linux/lib/mk/spec/x86_64/wireguard_lx_inc_dirs.mk +++ /dev/null @@ -1,14 +0,0 @@ -# -# For documentation see $(REP_DIR)/lib/mk/wireguard_lx_inc_dirs.inc . -# - -PRG_DIR := $(REP_DIR)/src/app/wireguard/spec/x86_64 - -SRC_S += arch/x86/crypto/poly1305-x86_64-cryptogams.S - -arch/x86/crypto/poly1305-x86_64-cryptogams.S: - $(MSG_CONVERT)$@ - $(VERBOSE)mkdir -p $(dir $@) - $(VERBOSE)perl $(LX_SRC_DIR)/arch/x86/crypto/poly1305-x86_64-cryptogams.pl > $@ - -include $(REP_DIR)/lib/mk/wireguard_lx_inc_dirs.inc diff --git a/repos/dde_linux/lib/mk/wireguard.inc b/repos/dde_linux/lib/mk/wireguard.inc index 4d5e6c858c..0a263f391f 100644 --- a/repos/dde_linux/lib/mk/wireguard.inc +++ b/repos/dde_linux/lib/mk/wireguard.inc @@ -1,39 +1,58 @@ -LIBS += base net jitterentropy wireguard_lx_inc_dirs +# +# This library is for avoiding clashes between Linux and Genode includes. +# If we were to compile all the *.c files of this library directly with the +# WireGuard library, there would be only one INC_DIR applied to *.cc files as +# well as to *.c files. Some Genode headers, however, (e.g. 'net/udp.h' or +# 'net/dhcp.h') exist with the same include identifier in both Linux and +# Genode, and we would have the problem that we want the Linux variant in *.c +# files and the Genode variant in *.cc files. Therefore, we create two +# dedicated INC_DIR settings through separate libraries. +# -#VIRT_LINUX_INCLUDE_DIR := $(call select_from_repositories,src/include/virt_linux) +SRC_C += $(notdir $(wildcard $(PRG_DIR)/generated_dummies.c)) +SRC_C += dummies.c +SRC_C += lx_emul.c +SRC_C += wireguard.c +SRC_C += genode_c_api_arch.c -DDE_LINUX_DIR := $(subst /src/include/lx_kit,,$(call select_from_repositories,src/include/lx_kit)) +vpath wireguard.c $(PRG_TOP_DIR)/genode_c_api +vpath %.c $(PRG_TOP_DIR) +vpath %.c $(PRG_DIR) -MUSL_TM_DIR = $(call select_from_repositories,src/lib/musl_tm) +INC_DIR += $(PRG_DIR) +INC_DIR += $(PRG_TOP_DIR) -INC_DIR += $(REP_DIR)/src/app/wireguard -INC_DIR += $(DDE_LINUX_DIR)/src/include/virt_linux -INC_DIR += $(DDE_LINUX_DIR)/src/include -INC_DIR += $(MUSL_TM_DIR) +LIBS += virt_lx_emul virt_linux_generated -ifeq ($(filter-out $(SPECS),x86_64),) -SPEC_ARCH := x86_64 -endif -ifeq ($(filter-out $(SPECS),arm_v8),) -SPEC_ARCH := arm_v8 -endif +# +# Some local files include linux headers that expect the KBUILD_* symbols to +# be defined. However, the lx_emul mechanism for adding the definitions doesn't +# apply to these files, which is why we have to do it manually. +# -INC_DIR += $(DDE_LINUX_DIR)/src/include/spec/$(SPEC_ARCH) +WG_KBUILD_DEFS := -DKBUILD_MODFILE='"wireguard"' \ + -DKBUILD_BASENAME='"wireguard"' \ + -DKBUILD_MODNAME='"wireguard"' -SRC_C += tm_to_secs.c +CC_OPT_wireguard += $(WG_KBUILD_DEFS) +CC_OPT_lx_emul += $(WG_KBUILD_DEFS) -SRC_CC += arp_cache.cc -SRC_CC += arp_waiter.cc -SRC_CC += base64.cc -SRC_CC += config_model.cc -SRC_CC += dhcp_client.cc -SRC_CC += ipv4_address_prefix.cc -SRC_CC += ipv4_config.cc -SRC_CC += lx_emul/random.cc -SRC_CC += main.cc -SRC_CC += nic_connection.cc -SRC_CC += uplink_connection.cc +# +# The lx_emul Makefiles have a generic mechanism for defining the +# KBUILD_MODFILE, KBUILD_BASENAME, and KBUILD_MODNAME for each Linux +# compilation unit to be unique. However, some WireGuard units expect +# KBUILD_MODNAME to be the same for all WireGuard units. Therefore, we +# let a target-specific variable override the CC_OPT_* variable for those +# units. +# -vpath tm_to_secs.c $(MUSL_TM_DIR) -vpath %.cc $(REP_DIR)/src/app/wireguard -vpath %.cc $(DDE_LINUX_DIR)/src/lib +OBJECTS_TO_FIX_CC_OPT_FOR := \ + drivers/net/wireguard/device.o \ + drivers/net/wireguard/netlink.o + +define FIX_OBJECT_CC_OPT = +$(1): override CC_OPT_$(1:%.o=%) = $(WG_KBUILD_DEFS) +endef + +$(foreach OBJECT,$(OBJECTS_TO_FIX_CC_OPT_FOR), \ + $(eval $(call FIX_OBJECT_CC_OPT,$(OBJECT)))) diff --git a/repos/dde_linux/lib/mk/wireguard_lx_inc_dirs.inc b/repos/dde_linux/lib/mk/wireguard_lx_inc_dirs.inc deleted file mode 100644 index 7d3c862518..0000000000 --- a/repos/dde_linux/lib/mk/wireguard_lx_inc_dirs.inc +++ /dev/null @@ -1,60 +0,0 @@ -# -# This library is for avoiding clashes between Linux and Genode includes. -# If we were to compile all the *.c files of this library directly with the -# WireGuard library, there would be only one INC_DIR applied to *.cc files as -# well as to *.c files. Some Genode headers, however, (e.g. 'net/udp.h' or -# 'net/dhcp.h') exist with the same include identifier in both Linux and -# Genode, and we would have the problem that we want the Linux variant in *.c -# files and the Genode variant in *.cc files. Therefore, we create two -# dedicated INC_DIR settings through separate libraries. -# - -GEN_PRG_DIR := $(PRG_DIR)/../.. - -SRC_C += $(notdir $(wildcard $(PRG_DIR)/generated_dummies.c)) -SRC_C += dummies.c -SRC_C += lx_emul.c -SRC_C += wireguard.c -SRC_C += genode_c_api_arch.c - -vpath wireguard.c $(GEN_PRG_DIR)/genode_c_api -vpath %.c $(PRG_DIR) -vpath %.c $(GEN_PRG_DIR) - -INC_DIR += $(PRG_DIR) -INC_DIR += $(GEN_PRG_DIR) - -LIBS += virt_lx_emul virt_linux_generated - -# -# Some local files include linux headers that expect the KBUILD_* symbols to -# be defined. However, the lx_emul mechanism for adding the definitions doesn't -# apply to these files, which is why we have to do it manually. -# - -WG_KBUILD_DEFS := -DKBUILD_MODFILE='"wireguard"' \ - -DKBUILD_BASENAME='"wireguard"' \ - -DKBUILD_MODNAME='"wireguard"' - -CC_OPT_wireguard += $(WG_KBUILD_DEFS) -CC_OPT_lx_emul += $(WG_KBUILD_DEFS) - -# -# The lx_emul Makefiles have a generic mechanism for defining the -# KBUILD_MODFILE, KBUILD_BASENAME, and KBUILD_MODNAME for each Linux -# compilation unit to be unique. However, some WireGuard units expect -# KBUILD_MODNAME to be the same for all WireGuard units. Therefore, we -# let a target-specific variable override the CC_OPT_* variable for those -# units. -# - -OBJECTS_TO_FIX_CC_OPT_FOR := \ - drivers/net/wireguard/device.o \ - drivers/net/wireguard/netlink.o - -define FIX_OBJECT_CC_OPT = -$(1): override CC_OPT_$(1:%.o=%) = $(WG_KBUILD_DEFS) -endef - -$(foreach OBJECT,$(OBJECTS_TO_FIX_CC_OPT_FOR), \ - $(eval $(call FIX_OBJECT_CC_OPT,$(OBJECT)))) diff --git a/repos/dde_linux/recipes/src/wireguard/content.mk b/repos/dde_linux/recipes/src/wireguard/content.mk index ab6c6335ff..a8a2da9347 100644 --- a/repos/dde_linux/recipes/src/wireguard/content.mk +++ b/repos/dde_linux/recipes/src/wireguard/content.mk @@ -1,11 +1,8 @@ MIRRORED_FROM_REP_DIR := \ lib/import/import-wireguard.mk \ lib/mk/spec/arm_v8/wireguard.mk \ - lib/mk/spec/arm_v8/wireguard_lx_inc_dirs.mk \ lib/mk/spec/x86_64/wireguard.mk \ - lib/mk/spec/x86_64/wireguard_lx_inc_dirs.mk \ lib/mk/wireguard.inc \ - lib/mk/wireguard_lx_inc_dirs.inc \ src/app/wireguard \ content: $(MIRRORED_FROM_REP_DIR) diff --git a/repos/dde_linux/src/app/wireguard/spec/arm_v8/target.mk b/repos/dde_linux/src/app/wireguard/spec/arm_v8/target.mk new file mode 100644 index 0000000000..8091dfba55 --- /dev/null +++ b/repos/dde_linux/src/app/wireguard/spec/arm_v8/target.mk @@ -0,0 +1,5 @@ +REQUIRES := arm_v8 + +INC_DIR += $(DDE_LINUX_DIR)/src/include/spec/arm_v8 + +include $(PRG_DIR)/../../target.inc diff --git a/repos/dde_linux/src/app/wireguard/spec/x86_64/target.mk b/repos/dde_linux/src/app/wireguard/spec/x86_64/target.mk new file mode 100644 index 0000000000..39efc6a072 --- /dev/null +++ b/repos/dde_linux/src/app/wireguard/spec/x86_64/target.mk @@ -0,0 +1,5 @@ +REQUIRES := x86_64 + +INC_DIR += $(DDE_LINUX_DIR)/src/include/spec/x86_64 + +include $(PRG_DIR)/../../target.inc diff --git a/repos/dde_linux/src/app/wireguard/target.inc b/repos/dde_linux/src/app/wireguard/target.inc new file mode 100644 index 0000000000..601dc9e54d --- /dev/null +++ b/repos/dde_linux/src/app/wireguard/target.inc @@ -0,0 +1,32 @@ +TARGET = wireguard + +LIBS += base net jitterentropy wireguard + +DDE_LINUX_DIR := $(subst /src/include/lx_kit,,$(call select_from_repositories,src/include/lx_kit)) + +MUSL_TM_DIR = $(call select_from_repositories,src/lib/musl_tm) + +INC_DIR += $(PRG_DIR)/../.. +INC_DIR += $(DDE_LINUX_DIR)/src/include/virt_linux +INC_DIR += $(DDE_LINUX_DIR)/src/include +INC_DIR += $(MUSL_TM_DIR) + +SRC_C += tm_to_secs.c + +SRC_CC += arp_cache.cc +SRC_CC += arp_waiter.cc +SRC_CC += base64.cc +SRC_CC += config_model.cc +SRC_CC += dhcp_client.cc +SRC_CC += ipv4_address_prefix.cc +SRC_CC += ipv4_config.cc +SRC_CC += lx_emul/random.cc +SRC_CC += main.cc +SRC_CC += nic_connection.cc +SRC_CC += uplink_connection.cc + +vpath tm_to_secs.c $(MUSL_TM_DIR) +vpath %.cc $(REP_DIR)/src/app/wireguard +vpath %.cc $(DDE_LINUX_DIR)/src/lib + +CONFIG_XSD := ../../config.xsd diff --git a/repos/dde_linux/src/app/wireguard/target.mk b/repos/dde_linux/src/app/wireguard/target.mk deleted file mode 100644 index 0148748a1f..0000000000 --- a/repos/dde_linux/src/app/wireguard/target.mk +++ /dev/null @@ -1,7 +0,0 @@ -TARGET = wireguard - -SRC_CC += dummy.cc - -LIBS += wireguard - -CONFIG_XSD := config.xsd