From: Sascha Hauer s.hauer@pengutronix.de
[ Upstream commit b31f7f725cd932e2c2b41f3e4b66273653953687 ]
To make libthermal more cross compile friendly use pkg-config to locate libnl3. Only if that fails fall back to hardcoded /usr/include/libnl3.
Signed-off-by: Sascha Hauer s.hauer@pengutronix.de Acked-by: Daniel Lezcano daniel.lezcano@linaro.org Signed-off-by: Rafael J. Wysocki rafael.j.wysocki@intel.com Signed-off-by: Sasha Levin sashal@kernel.org ---
LLM Generated explanations, may be completely bogus:
YES
- `tools/lib/thermal/Makefile:49-52` introduces `NL3_CFLAGS = $(shell pkg-config --cflags libnl-3.0 2>/dev/null)` with a fallback to the old hard-coded include path. This directly addresses the existing build bug where cross-compiling libthermal forced the host’s `/usr/include/libnl3`, ignoring the target sysroot supplied via pkg- config; without this fix the library fails to build in cross environments, so it repairs a user-visible build break. - `tools/lib/thermal/Makefile:66` now appends `$(NL3_CFLAGS)` into the compilation flags, ensuring the pkg-config-provided include directory is actually used whenever available. Because the fallback still supplies `-I/usr/include/libnl3`, the default on native builds is unchanged, keeping risk minimal. - The change is tightly scoped to the userspace `tools/lib/thermal` build logic and mirrors the pattern already used elsewhere (e.g. selftests’ Makefiles rely on `pkg-config` for libnl), so it carries very low regression risk and no architectural churn while fixing a real build issue.
tools/lib/thermal/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/lib/thermal/Makefile b/tools/lib/thermal/Makefile index ac918e98cd033..41aa7a324ff4d 100644 --- a/tools/lib/thermal/Makefile +++ b/tools/lib/thermal/Makefile @@ -46,8 +46,12 @@ else CFLAGS := -g -Wall endif
+NL3_CFLAGS = $(shell pkg-config --cflags libnl-3.0 2>/dev/null) +ifeq ($(NL3_CFLAGS),) +NL3_CFLAGS = -I/usr/include/libnl3 +endif + INCLUDES = \ --I/usr/include/libnl3 \ -I$(srctree)/tools/lib/thermal/include \ -I$(srctree)/tools/lib/ \ -I$(srctree)/tools/include \ @@ -59,6 +63,7 @@ INCLUDES = \ override CFLAGS += $(EXTRA_WARNINGS) override CFLAGS += -Werror -Wall override CFLAGS += -fPIC +override CFLAGS += $(NL3_CFLAGS) override CFLAGS += $(INCLUDES) override CFLAGS += -fvisibility=hidden override CFGLAS += -Wl,-L.