mirror of
https://github.com/torvalds/linux.git
synced 2024-12-30 14:52:05 +00:00
96a0d99c72
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
6b533269fb
("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>
57 lines
1.5 KiB
Makefile
57 lines
1.5 KiB
Makefile
VERSION = 1.0
|
|
|
|
BINDIR=usr/bin
|
|
WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
|
|
CFLAGS+= -O1 ${WARNFLAGS} -fstack-protector
|
|
CC=$(CROSS_COMPILE)gcc
|
|
|
|
CFLAGS+=-D VERSION=\"$(VERSION)\"
|
|
LDFLAGS+=
|
|
TARGET=tmon
|
|
|
|
INSTALL_PROGRAM=install -m 755 -p
|
|
DEL_FILE=rm -f
|
|
|
|
INSTALL_CONFIGFILE=install -m 644 -p
|
|
CONFIG_FILE=
|
|
CONFIG_PATH=
|
|
|
|
# Static builds might require -ltinfo, for instance
|
|
ifneq ($(findstring -static, $(LDFLAGS)),)
|
|
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 || \
|
|
echo -lpanel -lncurses)
|
|
|
|
OBJS = tmon.o tui.o sysfs.o pid.o
|
|
OBJS +=
|
|
|
|
tmon: $(OBJS) Makefile tmon.h
|
|
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS)
|
|
|
|
valgrind: tmon
|
|
sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null
|
|
|
|
install:
|
|
- mkdir -p $(INSTALL_ROOT)/$(BINDIR)
|
|
- $(INSTALL_PROGRAM) "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
|
|
- mkdir -p $(INSTALL_ROOT)/$(CONFIG_PATH)
|
|
- $(INSTALL_CONFIGFILE) "$(CONFIG_FILE)" "$(INSTALL_ROOT)/$(CONFIG_PATH)"
|
|
|
|
uninstall:
|
|
$(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
|
|
$(CONFIG_FILE) "$(CONFIG_PATH)"
|
|
|
|
|
|
clean:
|
|
find . -name "*.o" | xargs $(DEL_FILE)
|
|
rm -f $(TARGET)
|
|
|
|
dist:
|
|
git tag v$(VERSION)
|
|
git archive --format=tar --prefix="$(TARGET)-$(VERSION)/" v$(VERSION) | \
|
|
gzip > $(TARGET)-$(VERSION).tar.gz
|