Skip to contentSkip to conversation

tools/thermal: tmon: Allow overriding pkg-config

PATCH In review Florian Fainelli 2 participants 3 messages Aug 7, 2015 – Aug 8, 2015 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/thermal: tmon: Allow overriding pkg-config

Some build systems might not ship with a proper pkg-config infrastructure, so picking up the host pkg-config might cause us to link with ncursesw which may not be present in the build environment.

Allow an external build system to override the pkg-config value (e.g:
set it to /bin/false if we do not have anything).

Fixes 96a0d99c72cc ("tools/thermal: tmon: use pkg-config to determine library dependencies")
---
 tools/thermal/tmon/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/thermal/tmon/Makefile +3 -2
index 2e83dd3655a2..3777ab59d08c 100644
@@ -11,6 +11,7 @@ TARGET=tmon
 
 INSTALL_PROGRAM=install -m 755 -p
 DEL_FILE=rm -f
+PKG_CONFIG?=pkg-config
 
 # Static builds might require -ltinfo, for instance
 ifneq ($(findstring -static, $(LDFLAGS)),)
@@ -18,8 +19,8 @@ STATIC := --static
 endif
 
 TMON_LIBS=-lm -lpthread
-TMON_LIBS += $(shell pkg-config --libs $(STATIC) panelw ncursesw 2> /dev/null || \
-		     pkg-config --libs $(STATIC) panel ncurses 2> /dev/null || \
+TMON_LIBS += $(shell $(PKG_CONFIG) --libs $(STATIC) panelw ncursesw 2> /dev/null || \
+		     $(PKG_CONFIG) --libs $(STATIC) panel ncurses 2> /dev/null || \
 		     echo -lpanel -lncurses)
 
 OBJS = tmon.o tui.o sysfs.o pid.o
Signature · 1 line
2.1.0
#1 lore raw
Quoted 6 lines · Florian Fainelli

Some build systems might not ship with a proper pkg-config infrastructure, so picking up the host pkg-config might cause us to link with ncursesw which may not be present in the build environment.

Allow an external build system to override the pkg-config value (e.g:
set it to /bin/false if we do not have anything).

Is that really the best approach? I see other Makefiles that leave PKG_CONFIG as a variable (which is fine), but not to allow full override; they do something like:

PKG_CONFIG := $(CROSS_COMPILE)pkg-config

So, I suppose you could then alias your my-foo-cross-pkg-config to /bin/false, or something like that.

Another alternative: supply empty $PKG_CONFIG_LIBDIR and $PKG_CONFIG_PATH variables, so pkg-config finds nothing. (Bonus: no patch needed here!)

Brian

Quoted 32 lines
Fixes 96a0d99c72cc ("tools/thermal: tmon: use pkg-config to determine library dependencies")
---
 tools/thermal/tmon/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/thermal/tmon/Makefile +3 -2
index 2e83dd3655a2..3777ab59d08c 100644
@@ -11,6 +11,7 @@ TARGET=tmon
 
 INSTALL_PROGRAM=install -m 755 -p
 DEL_FILE=rm -f
+PKG_CONFIG?=pkg-config
 
 # Static builds might require -ltinfo, for instance
 ifneq ($(findstring -static, $(LDFLAGS)),)
@@ -18,8 +19,8 @@ STATIC := --static
 endif
 
 TMON_LIBS=-lm -lpthread
-TMON_LIBS += $(shell pkg-config --libs $(STATIC) panelw ncursesw 2> /dev/null || \
-		     pkg-config --libs $(STATIC) panel ncurses 2> /dev/null || \
+TMON_LIBS += $(shell $(PKG_CONFIG) --libs $(STATIC) panelw ncursesw 2> /dev/null || \
+		     $(PKG_CONFIG) --libs $(STATIC) panel ncurses 2> /dev/null || \
 		     echo -lpanel -lncurses)
 
 OBJS = tmon.o tui.o sysfs.o pid.o
Signature · 1 line
2.1.0
#2 lore raw
Quoted 11 lines · Brian Norris
Quoted 6 lines · Florian Fainelli

Some build systems might not ship with a proper pkg-config infrastructure, so picking up the host pkg-config might cause us to link with ncursesw which may not be present in the build environment.

Allow an external build system to override the pkg-config value (e.g:
set it to /bin/false if we do not have anything).

Is that really the best approach? I see other Makefiles that leave PKG_CONFIG as a variable (which is fine), but not to allow full override; they do something like:

For one, OpenWrt does provide a host pkg-config which is built as part of the build process (does not rely on the existing host pkg-config), setting CROSS_COMPILE to e.g: $(STAGING_DIR)/host/bin/ would look a little weird to me.

The other build environment (stblinux) does not have a valid pkg-config at all and this is what motivated this change in the first place.

Quoted 9 lines

PKG_CONFIG := $(CROSS_COMPILE)pkg-config

So, I suppose you could then alias your my-foo-cross-pkg-config to /bin/false, or something like that.

Another alternative: supply empty $PKG_CONFIG_LIBDIR and $PKG_CONFIG_PATH variables, so pkg-config finds nothing. (Bonus: no patch needed here!)

Humm, true that should work as well, I will give this some more testing, thanks!

Quoted 35 lines

Brian

Quoted 32 lines
Fixes 96a0d99c72cc ("tools/thermal: tmon: use pkg-config to determine library dependencies")
---
 tools/thermal/tmon/Makefile | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
tools/thermal/tmon/Makefile +3 -2
index 2e83dd3655a2..3777ab59d08c 100644
@@ -11,6 +11,7 @@ TARGET=tmon
 
 INSTALL_PROGRAM=install -m 755 -p
 DEL_FILE=rm -f
+PKG_CONFIG?=pkg-config
 
 # Static builds might require -ltinfo, for instance
 ifneq ($(findstring -static, $(LDFLAGS)),)
@@ -18,8 +19,8 @@ STATIC := --static
 endif
 
 TMON_LIBS=-lm -lpthread
-TMON_LIBS += $(shell pkg-config --libs $(STATIC) panelw ncursesw 2> /dev/null || \
-		     pkg-config --libs $(STATIC) panel ncurses 2> /dev/null || \
+TMON_LIBS += $(shell $(PKG_CONFIG) --libs $(STATIC) panelw ncursesw 2> /dev/null || \
+		     $(PKG_CONFIG) --libs $(STATIC) panel ncurses 2> /dev/null || \
 		     echo -lpanel -lncurses)
 
 OBJS = tmon.o tui.o sysfs.o pid.o
Signature · 1 line
2.1.0
Signature · 1 line
Florian