Skip to contentSkip to conversation

tools/power/x86/intel-speed-select: Use pkg-config for libnl-3.0 detection

PATCH In review Khem Raj 2 participants 2 messages Dec 29, 2025 – Dec 30, 2025

Subsystems (2)
lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 tools/power/x86/intel-speed-select: Use pkg-config for libnl-3.0 detection

Replace hardcoded libnl3 include path with pkg-config detection to improve portability across different distributions and build environments.

The previous implementation used a fixed path constructed from the compiler's sysroot, which could fail on systems with non-standard library installations. Now the build system:
- Attempts to detect libnl-3.0 include paths using pkg-config
- Falls back to /usr/include/libnl3 if pkg-config is unavailable
- Maintains backward compatibility with existing build configurations

This ensures the tool builds correctly on a wider range of systems while preserving existing behavior when pkg-config is not present.

---
 tools/power/x86/intel-speed-select/Makefile | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
tools/power/x86/intel-speed-select/Makefile +7 -1
index 8d3a02a20f3d..6b299aae2ded 100644
@@ -13,7 +13,13 @@ endif
 # Do not use make's built-in rules
 # (this improves performance and avoids hard-to-debug behaviour);
 MAKEFLAGS += -r
-override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include -I$(shell $(CC) -print-sysroot)/usr/include/libnl3
+
+NL3_CFLAGS = $(shell pkg-config --cflags libnl-3.0 2>/dev/null)
+ifeq ($(NL3_CFLAGS),)
+NL3_CFLAGS = -I/usr/include/libnl3
+endif
+
+override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include $(NL3_CFLAGS)
 override LDFLAGS += -lnl-genl-3 -lnl-3
 
 ALL_TARGETS := intel-speed-select
#1 lore raw
Quoted 11 lines · Khem Raj

Replace hardcoded libnl3 include path with pkg-config detection to improve portability across different distributions and build environments.

The previous implementation used a fixed path constructed from the compiler's sysroot, which could fail on systems with non-standard library installations. Now the build system:
- Attempts to detect libnl-3.0 include paths using pkg-config
- Falls back to /usr/include/libnl3 if pkg-config is unavailable
- Maintains backward compatibility with existing build configurations

Quoted 3 lines

This ensures the tool builds correctly on a wider range of systems while preserving existing behavior when pkg-config is not present.

Thanks for the patch. Will include as part of next PULL request.

-Srinivas

Quoted 28 lines

---
 tools/power/x86/intel-speed-select/Makefile | 8 +++++++-

 1 file changed, 7 insertions(+), 1 deletion(-)
tools/power/x86/intel-speed-select/Makefile +0 -0
index 8d3a02a20f3d..6b299aae2ded 100644
@@ -13,7 +13,13 @@ endif
  # Do not use make's built-in rules
  # (this improves performance and avoids hard-to-debug behaviour);

 MAKEFLAGS += -r
-override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include - I$(shell $(CC) -print-sysroot)/usr/include/libnl3

tools/power/x86/intel-speed-select/Makefile +7 -0
+
+NL3_CFLAGS = $(shell pkg-config --cflags libnl-3.0 2>/dev/null)
+ifeq ($(NL3_CFLAGS),)
+NL3_CFLAGS = -I/usr/include/libnl3
+endif
+
+override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include

$(NL3_CFLAGS)
 override LDFLAGS += -lnl-genl-3 -lnl-3

 ALL_TARGETS := intel-speed-select