@@ -1,4 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-or-later
+include feature/test-feature.mak
+
VERSION = 2.7
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
@@ -37,6 +39,19 @@ LDFLAGS ?=
PYLIB ?= $(shell python3 -m get_pylib)
+# Check for optional libcpupower dependency
+ifneq ($(no_libcpupower), 1)
+ifeq ($(call test-feature,libcpupower), 0)
+CPPFLAGS += -DHAVE_LIBCPUPOWER_SUPPORT
+LDFLAGS += -lcpupower
+else
+$(warning libcpupower is missing, building without --deepest-idle-state support.)
+$(warning Please install libcpupower-dev/kernel-tools-libs-devel)
+endif
+else
+$(warning libcpupower disabled, building without --deepest-idle-state support.)
+endif
+
# Check for errors, such as python3 not available
ifeq (${PYLIB},)
undefine PYLIB
new file mode 100644
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+all: feature-libcpupower
+
+feature-libcpupower: $(OBJDIR)/test-libcpupower.o
+
+$(OBJDIR)/test-libcpupower.o: feature/test-libcpupower.c
+ @$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $< -lcpupower -o $@
+
+.PHONY: clean
+
+clean:
+ rm -f $(OBJDIR)/test-*.o
new file mode 100644
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+define test-feature
+$(shell $(MAKE) OBJDIR=$(OBJDIR) CFLAGS=$(CFLAGS) CPPFLAGS=$(CPPFLAGS) LDFLAGS=$(LDFLAGS) \
+-f feature/Makefile feature-$1 clean >/dev/null 2>/dev/null; echo $$?)
+endef
new file mode 100644
@@ -0,0 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include <cpuidle.h>
+
+int main(void)
+{
+ int rv = cpuidle_state_count(0);
+ return rv;
+}