* [PATCH 0/6] tools/thermal: Build fixes
@ 2025-08-11 6:59 Eugen Hristev
2025-08-11 6:59 ` [PATCH 1/6] tools/Makefile: Add dependency on thermal for thermal-engine Eugen Hristev
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: Eugen Hristev @ 2025-08-11 6:59 UTC (permalink / raw)
To: rafael, daniel.lezcano, linux-pm; +Cc: linux-kernel, Eugen Hristev
Some assorted fixes for thermal tools Makefiles to aid in building/cross
building.
Eugen Hristev (6):
tools/Makefile: Add dependency on thermal for thermal-engine
tools/lib/thermal: Fix dependency to host libnl
tools/thermal/lib: Fix header file installation
tools/thermal/lib: Fix dependency to host libnl
tools/thermal: Fix thermometer/thermal-engine thermal tools dependency
tools/thermal/thermal-engine: Add cross compile support
tools/Makefile | 10 ++++-
tools/lib/thermal/Makefile | 7 +++-
tools/thermal/lib/Makefile | 9 +++-
tools/thermal/thermal-engine/Makefile | 60 ++++++++++++++++++++-------
4 files changed, 66 insertions(+), 20 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/6] tools/Makefile: Add dependency on thermal for thermal-engine
2025-08-11 6:59 [PATCH 0/6] tools/thermal: Build fixes Eugen Hristev
@ 2025-08-11 6:59 ` Eugen Hristev
2025-08-11 6:59 ` [PATCH 2/6] tools/lib/thermal: Fix dependency to host libnl Eugen Hristev
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eugen Hristev @ 2025-08-11 6:59 UTC (permalink / raw)
To: rafael, daniel.lezcano, linux-pm; +Cc: linux-kernel, Eugen Hristev
thermal-engine requires thermal to build, and the dependency is in place.
It is then obvious that install and clean targets should also depend on
the corresponding thermal target.
Signed-off-by: Eugen Hristev <eugen.hristev@linaro.org>
---
tools/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/Makefile b/tools/Makefile
index c31cbbd12c45..a4f5577210f1 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -152,7 +152,7 @@ tmon_install:
thermometer_install:
$(call descend,thermal/$(@:_install=),install)
-thermal-engine_install:
+thermal-engine_install: thermal_install
$(call descend,thermal/$(@:_install=),install)
freefall_install:
@@ -209,7 +209,7 @@ turbostat_clean x86_energy_perf_policy_clean intel-speed-select_clean:
thermometer_clean:
$(call descend,thermal/thermometer,clean)
-thermal-engine_clean:
+thermal-engine_clean: thermal_clean
$(call descend,thermal/thermal-engine,clean)
tmon_clean:
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/6] tools/lib/thermal: Fix dependency to host libnl
2025-08-11 6:59 [PATCH 0/6] tools/thermal: Build fixes Eugen Hristev
2025-08-11 6:59 ` [PATCH 1/6] tools/Makefile: Add dependency on thermal for thermal-engine Eugen Hristev
@ 2025-08-11 6:59 ` Eugen Hristev
2025-08-11 6:59 ` [PATCH 3/6] tools/thermal/lib: Fix header file installation Eugen Hristev
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eugen Hristev @ 2025-08-11 6:59 UTC (permalink / raw)
To: rafael, daniel.lezcano, linux-pm; +Cc: linux-kernel, Eugen Hristev
The include path should be created according to host pkg-config
especially when building with a different sysroot or cross compiling.
Thus, call the pkg-config to obtain the correct path instead of
accessing directly from root host file system, which is incorrect.
Fixes: 47c4b0de080a ("tools/lib/thermal: Add a thermal library")
Signed-off-by: Eugen Hristev <eugen.hristev@linaro.org>
---
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 a1f5e388644d..ea56b55c9fcb 100644
--- a/tools/lib/thermal/Makefile
+++ b/tools/lib/thermal/Makefile
@@ -47,7 +47,6 @@ else
endif
INCLUDES = \
--I/usr/include/libnl3 \
-I$(srctree)/tools/lib/thermal/include \
-I$(srctree)/tools/lib/ \
-I$(srctree)/tools/include \
@@ -55,6 +54,12 @@ INCLUDES = \
-I$(srctree)/tools/arch/$(SRCARCH)/include/uapi \
-I$(srctree)/tools/include/uapi
+VAR_INCLUDES = $(shell pkg-config --cflags libnl-3.0 libnl-genl-3.0 2>/dev/null)
+ifeq ($(VAR_INCLUDES),)
+VAR_INCLUDES = -I/usr/include/libnl3
+endif
+override CFLAGS += $(VAR_INCLUDES)
+
# Append required CFLAGS
override CFLAGS += $(EXTRA_WARNINGS)
override CFLAGS += -Werror -Wall
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/6] tools/thermal/lib: Fix header file installation
2025-08-11 6:59 [PATCH 0/6] tools/thermal: Build fixes Eugen Hristev
2025-08-11 6:59 ` [PATCH 1/6] tools/Makefile: Add dependency on thermal for thermal-engine Eugen Hristev
2025-08-11 6:59 ` [PATCH 2/6] tools/lib/thermal: Fix dependency to host libnl Eugen Hristev
@ 2025-08-11 6:59 ` Eugen Hristev
2025-08-11 6:59 ` [PATCH 4/6] tools/thermal/lib: Fix dependency to host libnl Eugen Hristev
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eugen Hristev @ 2025-08-11 6:59 UTC (permalink / raw)
To: rafael, daniel.lezcano, linux-pm; +Cc: linux-kernel, Eugen Hristev
The header file created by this lib is thermal-tools.h and not thermal.h
Fix it accordingly.
Fixes: 3b7c5e8adf9c ("tools/thermal: Add util library")
Signed-off-by: Eugen Hristev <eugen.hristev@linaro.org>
---
tools/thermal/lib/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/thermal/lib/Makefile b/tools/thermal/lib/Makefile
index 056d212f25cf..b8fded7f22b8 100644
--- a/tools/thermal/lib/Makefile
+++ b/tools/thermal/lib/Makefile
@@ -128,7 +128,7 @@ install_lib: libs
install_headers:
$(call QUIET_INSTALL, headers) \
- $(call do_install,include/thermal.h,$(prefix)/include/thermal,644); \
+ $(call do_install,thermal-tools.h,$(prefix)/include/thermal,644); \
install_pkgconfig: $(LIBTHERMAL_TOOLS_PC)
$(call QUIET_INSTALL, $(LIBTHERMAL_TOOLS_PC)) \
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/6] tools/thermal/lib: Fix dependency to host libnl
2025-08-11 6:59 [PATCH 0/6] tools/thermal: Build fixes Eugen Hristev
` (2 preceding siblings ...)
2025-08-11 6:59 ` [PATCH 3/6] tools/thermal/lib: Fix header file installation Eugen Hristev
@ 2025-08-11 6:59 ` Eugen Hristev
2025-08-11 6:59 ` [PATCH 5/6] tools/thermal: Fix thermometer/thermal-engine thermal tools dependency Eugen Hristev
2025-08-11 6:59 ` [PATCH 6/6] tools/thermal/thermal-engine: Add cross compile support Eugen Hristev
5 siblings, 0 replies; 7+ messages in thread
From: Eugen Hristev @ 2025-08-11 6:59 UTC (permalink / raw)
To: rafael, daniel.lezcano, linux-pm; +Cc: linux-kernel, Eugen Hristev
The include path should be created according to host pkg-config
especially when building with a different sysroot or cross compiling.
Thus, call the pkg-config to obtain the correct path instead of
accessing directly from root host file system, which is incorrect.
Fixes: 3b7c5e8adf9c ("tools/thermal: Add util library")
Signed-off-by: Eugen Hristev <eugen.hristev@linaro.org>
---
tools/thermal/lib/Makefile | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/tools/thermal/lib/Makefile b/tools/thermal/lib/Makefile
index b8fded7f22b8..51a2a2ab7de8 100644
--- a/tools/thermal/lib/Makefile
+++ b/tools/thermal/lib/Makefile
@@ -47,7 +47,6 @@ else
endif
INCLUDES = \
--I/usr/include/libnl3 \
-I$(srctree)/tools/lib/thermal/include \
-I$(srctree)/tools/lib/ \
-I$(srctree)/tools/include \
@@ -55,6 +54,12 @@ INCLUDES = \
-I$(srctree)/tools/arch/$(SRCARCH)/include/uapi \
-I$(srctree)/tools/include/uapi
+VAR_INCLUDES = $(shell pkg-config --cflags libnl-3.0 libnl-genl-3.0 2>/dev/null)
+ifeq ($(VAR_INCLUDES),)
+VAR_INCLUDES = -I/usr/include/libnl3
+endif
+override CFLAGS += $(VAR_INCLUDES)
+
# Append required CFLAGS
override CFLAGS += $(EXTRA_WARNINGS)
override CFLAGS += -Werror -Wall
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 5/6] tools/thermal: Fix thermometer/thermal-engine thermal tools dependency
2025-08-11 6:59 [PATCH 0/6] tools/thermal: Build fixes Eugen Hristev
` (3 preceding siblings ...)
2025-08-11 6:59 ` [PATCH 4/6] tools/thermal/lib: Fix dependency to host libnl Eugen Hristev
@ 2025-08-11 6:59 ` Eugen Hristev
2025-08-11 6:59 ` [PATCH 6/6] tools/thermal/thermal-engine: Add cross compile support Eugen Hristev
5 siblings, 0 replies; 7+ messages in thread
From: Eugen Hristev @ 2025-08-11 6:59 UTC (permalink / raw)
To: rafael, daniel.lezcano, linux-pm; +Cc: linux-kernel, Eugen Hristev
Thermometer and thermal engine depend on thermal tools library.
This lib should be built and installed accordingly.
Fixes: 110acbc6a451 ("tools/thermal: Add a temperature capture tool")
Fixes: 077df623c834 ("tools/thermal: Add thermal daemon skeleton")
Signed-off-by: Eugen Hristev <eugen.hristev@linaro.org>
---
tools/Makefile | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/Makefile b/tools/Makefile
index a4f5577210f1..9cc71b302b19 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -108,9 +108,11 @@ tmon: FORCE
$(call descend,thermal/$@)
thermometer: FORCE
+ $(call descend,thermal/lib)
$(call descend,thermal/$@)
thermal-engine: FORCE thermal
+ $(call descend,thermal/lib)
$(call descend,thermal/$@)
freefall: FORCE
@@ -150,9 +152,11 @@ tmon_install:
$(call descend,thermal/$(@:_install=),install)
thermometer_install:
+ $(call descend,thermal/lib/,install)
$(call descend,thermal/$(@:_install=),install)
thermal-engine_install: thermal_install
+ $(call descend,thermal/lib/,install)
$(call descend,thermal/$(@:_install=),install)
freefall_install:
@@ -207,9 +211,11 @@ turbostat_clean x86_energy_perf_policy_clean intel-speed-select_clean:
$(call descend,power/x86/$(@:_clean=),clean)
thermometer_clean:
+ $(call descend,thermal/lib,clean)
$(call descend,thermal/thermometer,clean)
thermal-engine_clean: thermal_clean
+ $(call descend,thermal/lib,clean)
$(call descend,thermal/thermal-engine,clean)
tmon_clean:
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 6/6] tools/thermal/thermal-engine: Add cross compile support
2025-08-11 6:59 [PATCH 0/6] tools/thermal: Build fixes Eugen Hristev
` (4 preceding siblings ...)
2025-08-11 6:59 ` [PATCH 5/6] tools/thermal: Fix thermometer/thermal-engine thermal tools dependency Eugen Hristev
@ 2025-08-11 6:59 ` Eugen Hristev
5 siblings, 0 replies; 7+ messages in thread
From: Eugen Hristev @ 2025-08-11 6:59 UTC (permalink / raw)
To: rafael, daniel.lezcano, linux-pm; +Cc: linux-kernel, Eugen Hristev
Adapt the Makefile for cross compilation.
Took tmon as reference, and adapted the Makefile for thermal-engine.
Signed-off-by: Eugen Hristev <eugen.hristev@linaro.org>
---
tools/thermal/thermal-engine/Makefile | 60 ++++++++++++++++++++-------
1 file changed, 45 insertions(+), 15 deletions(-)
diff --git a/tools/thermal/thermal-engine/Makefile b/tools/thermal/thermal-engine/Makefile
index 6bd05ff89485..539c643804fb 100644
--- a/tools/thermal/thermal-engine/Makefile
+++ b/tools/thermal/thermal-engine/Makefile
@@ -1,5 +1,8 @@
# SPDX-License-Identifier: GPL-2.0
-# Makefile for thermal tools
+# Makefile for thermal engine
+include ../../build/Build.include
+
+VERSION = 0.0.1
ifeq ($(srctree),)
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
@@ -8,21 +11,48 @@ srctree := $(patsubst %/,%,$(dir $(srctree)))
# $(info Determined 'srctree' to be $(srctree))
endif
-CFLAGS = -Wall -Wextra
-CFLAGS += -I$(srctree)/tools/thermal/lib
-CFLAGS += -I$(srctree)/tools/lib/thermal/include
+BINDIR=usr/bin
+WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
+override CFLAGS+= $(call cc-option,-O3,-O1) ${WARNFLAGS}
+# Add "-fstack-protector" only if toolchain supports it.
+override CFLAGS+= $(call cc-option,-fstack-protector-strong)
+CC?= $(CROSS_COMPILE)gcc
+PKG_CONFIG?= $(CROSS_COMPILE)pkg-config
-LDFLAGS = -L$(srctree)/tools/thermal/lib
-LDFLAGS += -L$(srctree)/tools/lib/thermal
-LDFLAGS += -lthermal_tools
-LDFLAGS += -lthermal
-LDFLAGS += -lconfig
-LDFLAGS += -lnl-genl-3 -lnl-3
+override CFLAGS+=-D VERSION=\"$(VERSION)\"
+TARGET=thermal-engine
-VERSION = 0.0.1
+override CFLAGS += -I$(srctree)/tools/thermal/lib
+override CFLAGS += -I$(srctree)/tools/lib/thermal/include
+
+override LDFLAGS += -L$(srctree)/tools/thermal/lib
+override LDFLAGS += -L$(srctree)/tools/lib/thermal
+
+INSTALL_PROGRAM=install -m 755 -p
+DEL_FILE=rm -f
+
+# Static builds might require -ltinfo, for instance
+ifneq ($(findstring -static, $(LDFLAGS)),)
+STATIC := --static
+endif
+
+THERMAL_ENGINE_LIBS=-lconfig -lnl-genl-3 -lnl-3 -lthermal -lthermal_tools
+
+OBJS = thermal-engine.o
+
+thermal-engine: $(OBJS) Makefile
+ $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(THERMAL_ENGINE_LIBS)
+
+install:
+ - $(INSTALL_PROGRAM) -D "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
+
+uninstall:
+ $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
-all: thermal-engine
-%: %.c
- $(CC) $(CFLAGS) -D VERSION=\"$(VERSION)\" -o $@ $^ $(LDFLAGS)
clean:
- $(RM) thermal-engine
+ rm -f $(TARGET) $(OBJS)
+
+dist:
+ git tag v$(VERSION)
+ git archive --format=tar --prefix="$(TARGET)-$(VERSION)/" v$(VERSION) | \
+ gzip > $(TARGET)-$(VERSION).tar.gz
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-08-11 7:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 6:59 [PATCH 0/6] tools/thermal: Build fixes Eugen Hristev
2025-08-11 6:59 ` [PATCH 1/6] tools/Makefile: Add dependency on thermal for thermal-engine Eugen Hristev
2025-08-11 6:59 ` [PATCH 2/6] tools/lib/thermal: Fix dependency to host libnl Eugen Hristev
2025-08-11 6:59 ` [PATCH 3/6] tools/thermal/lib: Fix header file installation Eugen Hristev
2025-08-11 6:59 ` [PATCH 4/6] tools/thermal/lib: Fix dependency to host libnl Eugen Hristev
2025-08-11 6:59 ` [PATCH 5/6] tools/thermal: Fix thermometer/thermal-engine thermal tools dependency Eugen Hristev
2025-08-11 6:59 ` [PATCH 6/6] tools/thermal/thermal-engine: Add cross compile support Eugen Hristev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).