1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
Origin: upstream, 2bdebac7d3002aa083d8f302072adb181501aec1
From: "Storm, Christian" <christian.storm@siemens.com>
Date: Tue, 27 May 2025 07:37:49 +0000
Subject: suricatta: Fix out-of-tree build
With commit 16554cd, CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE is prepended
by $(srctree)/ if a / is found in CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE.
This is the case for absolute paths as well as for relative paths such
as the default "suricatta/server_wfx.lua" if CONFIG_SURICATTA_WFX.
While the latter case resolves correctly, the former is broken.
Hence, properly tokenize CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE and
prepend $(srctree)/ only if / is not found in the first token, i.e,
it's an absolute path.
While at it, issue an error message if the relative path referenced
to by CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE cannot be resolved.
Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
Makefile.flags | 10 ++++++++--
test/Makefile | 10 ++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/Makefile.flags b/Makefile.flags
index 38c14078..25ae4e8f 100644
--- a/Makefile.flags
+++ b/Makefile.flags
@@ -263,8 +263,14 @@ ifneq ($(CONFIG_SURICATTA),)
ifneq ($(CONFIG_SURICATTA_LUA),)
ifneq ($(CONFIG_EMBEDDED_SURICATTA_LUA),)
ifneq ($(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE),)
-ifneq ($(findstring /, $(firstword $(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE))),)
- CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE := $(srctree)/$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE)
+# Strip quotes from filename
+CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE := $(patsubst "%",%,$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE))
+ifeq ($(findstring /,$(word 1,$(subst /, /,$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE)))),)
+# It's not an absolute path, assume it's relative to $(srcdir)
+ifeq ($(realpath $(srctree)/$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE)),)
+$(error File specified in CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE=$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE) not found)
+endif
+CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE := $(realpath $(srctree)/$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE))
endif
LDFLAGS_swupdate += -Wl,--format=binary -Wl,$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE) -Wl,--format=default
KBUILD_CPPFLAGS += -DEMBEDDED_SURICATTA_LUA_SOURCE_START="_binary_$(strip $(subst -,_,$(subst +,_,$(subst ",,$(subst .,_,$(subst /,_,$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE)))))))_start"
diff --git a/test/Makefile b/test/Makefile
index e4f576c4..cc5f5f47 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -40,8 +40,14 @@ ifneq ($(CONFIG_EXTRA_LDFLAGS),)
EXTRA_LDFLAGS += $($(STRIP) $(subst ",,$(CONFIG_EXTRA_LDFLAGS)))#"))
endif
ifneq ($(CONFIG_EMBEDDED_SURICATTA_LUA),)
-ifneq ($(findstring /, $(firstword $(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE))),)
- CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE := $(srctree)/$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE)
+# Strip quotes from filename
+CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE := $(patsubst "%",%,$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE))
+ifeq ($(findstring /,$(word 1,$(subst /, /,$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE)))),)
+# It's not an absolute path, assume it's relative to $(srcdir)
+ifeq ($(realpath $(srctree)/$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE)),)
+$(error File specified in CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE=$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE) not found)
+endif
+CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE := $(realpath $(srctree)/$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE))
endif
EXTRA_LDFLAGS += -Wl,--format=binary -Wl,$(CONFIG_EMBEDDED_SURICATTA_LUA_SOURCE) -Wl,--format=default
endif
|