From 83408ef35c407f983de02b752e371a68589d7e21 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Mon, 23 May 2022 12:48:30 +0200 Subject: [PATCH] wireguard: rename wireguard lib The wireguard library's purpose is having a separate INC_DIR setting for the files that need Linux include paths that would clash with Genode include paths. Therefore, the name wireguard_lx_inc_dirs is more descriptive. Furthermore, this allows us to create a new arch-specific wireguard lib in a future commit in the course of preventing arch-specific target.mk's (a commonly used approach in Genode). Ref #4519 --- ...{wireguard.mk => wireguard_lx_inc_dirs.mk} | 5 +-- ...{wireguard.mk => wireguard_lx_inc_dirs.mk} | 4 +-- ...ireguard.inc => wireguard_lx_inc_dirs.inc} | 35 +++++++++++++------ repos/dde_linux/src/app/wireguard/target.inc | 2 +- 4 files changed, 30 insertions(+), 16 deletions(-) rename repos/dde_linux/lib/mk/spec/arm_64/{wireguard.mk => wireguard_lx_inc_dirs.mk} (83%) rename repos/dde_linux/lib/mk/spec/x86_64/{wireguard.mk => wireguard_lx_inc_dirs.mk} (65%) rename repos/dde_linux/lib/mk/{wireguard.inc => wireguard_lx_inc_dirs.inc} (69%) diff --git a/repos/dde_linux/lib/mk/spec/arm_64/wireguard.mk b/repos/dde_linux/lib/mk/spec/arm_64/wireguard_lx_inc_dirs.mk similarity index 83% rename from repos/dde_linux/lib/mk/spec/arm_64/wireguard.mk rename to repos/dde_linux/lib/mk/spec/arm_64/wireguard_lx_inc_dirs.mk index 5becda2d3f..fc175013ee 100644 --- a/repos/dde_linux/lib/mk/spec/arm_64/wireguard.mk +++ b/repos/dde_linux/lib/mk/spec/arm_64/wireguard_lx_inc_dirs.mk @@ -1,5 +1,5 @@ # -# For documentation see $(REP_DIR)/lib/mk/wireguard.inc . +# For documentation see $(REP_DIR)/lib/mk/wireguard_lx_inc_dirs.inc . # PRG_DIR := $(REP_DIR)/src/app/wireguard/spec/arm_64 @@ -20,4 +20,5 @@ arch/arm64/crypto/poly1305-core.S: CC_OPT_arch/arm64/crypto/poly1305-core += -Dpoly1305_init=poly1305_init_arm64 -include $(REP_DIR)/lib/mk/wireguard.inc +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_lx_inc_dirs.mk similarity index 65% rename from repos/dde_linux/lib/mk/spec/x86_64/wireguard.mk rename to repos/dde_linux/lib/mk/spec/x86_64/wireguard_lx_inc_dirs.mk index e51e4e805b..18a49b8891 100644 --- a/repos/dde_linux/lib/mk/spec/x86_64/wireguard.mk +++ b/repos/dde_linux/lib/mk/spec/x86_64/wireguard_lx_inc_dirs.mk @@ -1,5 +1,5 @@ # -# For documentation see $(REP_DIR)/lib/mk/wireguard.inc . +# For documentation see $(REP_DIR)/lib/mk/wireguard_lx_inc_dirs.inc . # PRG_DIR := $(REP_DIR)/src/app/wireguard/spec/x86_64 @@ -9,4 +9,4 @@ SRC_S += arch/x86/crypto/poly1305-x86_64-cryptogams.S arch/x86/crypto/poly1305-x86_64-cryptogams.S: perl $(LX_SRC_DIR)/arch/x86/crypto/poly1305-x86_64-cryptogams.pl > $@ -include $(REP_DIR)/lib/mk/wireguard.inc +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_lx_inc_dirs.inc similarity index 69% rename from repos/dde_linux/lib/mk/wireguard.inc rename to repos/dde_linux/lib/mk/wireguard_lx_inc_dirs.inc index da0af3d3ce..be0821dfc1 100644 --- a/repos/dde_linux/lib/mk/wireguard.inc +++ b/repos/dde_linux/lib/mk/wireguard_lx_inc_dirs.inc @@ -1,7 +1,7 @@ # # 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 target there would be only one INC_DIR applied to *.cc files as +# WireGuard target 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 @@ -18,29 +18,42 @@ SRC_C += lx_emul.c SRC_C += wireguard.c SRC_C += genode_c_api_arch.c -vpath lx_emul/alloc.cc $(GEN_PRG_DIR) -vpath lx_kit/memory.cc $(GEN_PRG_DIR) -vpath wireguard.c $(GEN_PRG_DIR)/genode_c_api -vpath %.c $(PRG_DIR) -vpath %.c $(GEN_PRG_DIR) +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 += lx_emul virt_linux_generated +# +# We shadow some files of lx_emul and lx_kit in order to locally apply +# modifications. +# + +vpath lx_emul/alloc.cc $(GEN_PRG_DIR) +vpath lx_kit/memory.cc $(GEN_PRG_DIR) + +# +# 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 local files, which is why we have to add them manually. +# + CC_OPT_wireguard += -DKBUILD_MODFILE='"wireguard"' \ -DKBUILD_BASENAME='"wireguard"' \ -DKBUILD_MODNAME='"wireguard"' -CC_OPT_lx_emul += -DKBUILD_MODFILE='"lx_emul"' \ - -DKBUILD_BASENAME='"lx_emul"' \ - -DKBUILD_MODNAME='"lx_emul"' + +CC_OPT_lx_emul += -DKBUILD_MODFILE='"lx_emul"' \ + -DKBUILD_BASENAME='"lx_emul"' \ + -DKBUILD_MODNAME='"lx_emul"' # # The lx_emul Makefiles have a generic mechanism for defining the # KBUILD_MODNAME for each Linux unit to be the filename of that unit -# (without suffix). However, some Wireguard units expect -# KBUILD_MODNAME to be the same for all Wireguard units. +# (without suffix). However, some WireGuard units expect +# KBUILD_MODNAME to be the same for all WireGuard units. # Therefore, we do a pattern substition on the CC_OPT_* variables of # those units, changing their KBUILD_MODNAME def to "wireguard". # diff --git a/repos/dde_linux/src/app/wireguard/target.inc b/repos/dde_linux/src/app/wireguard/target.inc index 0080d06b74..58b25190d4 100644 --- a/repos/dde_linux/src/app/wireguard/target.inc +++ b/repos/dde_linux/src/app/wireguard/target.inc @@ -1,5 +1,5 @@ TARGET = wireguard -LIBS += base net jitterentropy wireguard +LIBS += base net jitterentropy wireguard_lx_inc_dirs GEN_DIR := $(PRG_DIR)/../.. INC_DIR += $(GEN_DIR) INC_DIR += $(REP_DIR)/src/include