diff options
| author | Brian Norris <computersforpeace@gmail.com> | 2015-02-17 21:18:35 -0500 |
|---|---|---|
| committer | Zhang Rui <rui.zhang@intel.com> | 2015-02-28 00:52:48 -0500 |
| commit | 96a0d99c72cc4eb4f1b2acb71580693b91b95b28 (patch) | |
| tree | bd37b442b83cb25e611c4f4da8b5c85cf0bca09b | |
| parent | 1b0eaa2cc2dc52dced546c1c8b0551cfc734d32d (diff) | |
tools/thermal: tmon: use pkg-config to determine library dependencies
Some distros (e.g., Arch Linux) don't package the tinfo library
separately from ncurses, so don't unconditionally include it. Instead,
use pkg-config.
The $(STATIC) ugliness is to handle the reported build case from commit
6b533269fb25 ("tools/thermal: tmon: fix compilation errors when building
statically"), where a developer wants to be able to build with:
make LDFLAGS=-static
which requires an additional pkg-config flag.
Finally, support a lowest common denominator fallback (-lpanel
-lncurses) for build systems that don't have pkg-config entries for
ncurses.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Acked-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
| -rw-r--r-- | tools/thermal/tmon/Makefile | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile index 13d1876c7889..0788621c8d76 100644 --- a/tools/thermal/tmon/Makefile +++ b/tools/thermal/tmon/Makefile | |||
| @@ -16,12 +16,21 @@ INSTALL_CONFIGFILE=install -m 644 -p | |||
| 16 | CONFIG_FILE= | 16 | CONFIG_FILE= |
| 17 | CONFIG_PATH= | 17 | CONFIG_PATH= |
| 18 | 18 | ||
| 19 | # Static builds might require -ltinfo, for instance | ||
| 20 | ifneq ($(findstring -static, $(LDFLAGS)),) | ||
| 21 | STATIC := --static | ||
| 22 | endif | ||
| 23 | |||
| 24 | TMON_LIBS=-lm -lpthread | ||
| 25 | TMON_LIBS += $(shell pkg-config --libs $(STATIC) panelw ncursesw 2> /dev/null || \ | ||
| 26 | pkg-config --libs $(STATIC) panel ncurses 2> /dev/null || \ | ||
| 27 | echo -lpanel -lncurses) | ||
| 19 | 28 | ||
| 20 | OBJS = tmon.o tui.o sysfs.o pid.o | 29 | OBJS = tmon.o tui.o sysfs.o pid.o |
| 21 | OBJS += | 30 | OBJS += |
| 22 | 31 | ||
| 23 | tmon: $(OBJS) Makefile tmon.h | 32 | tmon: $(OBJS) Makefile tmon.h |
| 24 | $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -ltinfo -lpthread | 33 | $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS) |
| 25 | 34 | ||
| 26 | valgrind: tmon | 35 | valgrind: tmon |
| 27 | sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null | 36 | sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null |
