[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250811065915.3333142-7-eugen.hristev@linaro.org>
Date: Mon, 11 Aug 2025 09:59:15 +0300
From: Eugen Hristev <eugen.hristev@...aro.org>
To: rafael@...nel.org,
daniel.lezcano@...aro.org,
linux-pm@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
Eugen Hristev <eugen.hristev@...aro.org>
Subject: [PATCH 6/6] tools/thermal/thermal-engine: Add cross compile support
Adapt the Makefile for cross compilation.
Took tmon as reference, and adapted the Makefile for thermal-engine.
Signed-off-by: Eugen Hristev <eugen.hristev@...aro.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
Powered by blists - more mailing lists