Merge tag 'affs-for-6.1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave...
[linux-block.git] / tools / thermal / tmon / Makefile
CommitLineData
b2441318 1# SPDX-License-Identifier: GPL-2.0
ec04aa3a 2# We need this for the "cc-option" macro.
b61442df 3include ../../build/Build.include
ec04aa3a 4
94f69966
JP
5VERSION = 1.0
6
7BINDIR=usr/bin
8WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
302df34c 9override CFLAGS+= $(call cc-option,-O3,-O1) ${WARNFLAGS}
ec04aa3a 10# Add "-fstack-protector" only if toolchain supports it.
ad6b474f 11override CFLAGS+= $(call cc-option,-fstack-protector-strong)
c21568ff 12CC?= $(CROSS_COMPILE)gcc
b5f7912b 13PKG_CONFIG?= $(CROSS_COMPILE)pkg-config
94f69966 14
ad6b474f 15override CFLAGS+=-D VERSION=\"$(VERSION)\"
94f69966
JP
16TARGET=tmon
17
18INSTALL_PROGRAM=install -m 755 -p
19DEL_FILE=rm -f
20
96a0d99c
BN
21# Static builds might require -ltinfo, for instance
22ifneq ($(findstring -static, $(LDFLAGS)),)
23STATIC := --static
24endif
25
26TMON_LIBS=-lm -lpthread
501a5c71
MM
27TMON_LIBS += $(shell $(PKG_CONFIG) --libs $(STATIC) panelw ncursesw 2> /dev/null || \
28 $(PKG_CONFIG) --libs $(STATIC) panel ncurses 2> /dev/null || \
96a0d99c 29 echo -lpanel -lncurses)
94f69966 30
ad6b474f 31override CFLAGS += $(shell $(PKG_CONFIG) --cflags $(STATIC) panelw ncursesw 2> /dev/null || \
501a5c71 32 $(PKG_CONFIG) --cflags $(STATIC) panel ncurses 2> /dev/null)
809b6ecb 33
94f69966 34OBJS = tmon.o tui.o sysfs.o pid.o
94f69966
JP
35
36tmon: $(OBJS) Makefile tmon.h
96a0d99c 37 $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(TARGET) $(TMON_LIBS)
94f69966
JP
38
39valgrind: tmon
40 sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null
41
42install:
99d88c30 43 - $(INSTALL_PROGRAM) -D "$(TARGET)" "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
94f69966
JP
44
45uninstall:
46 $(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
94f69966
JP
47
48clean:
99d88c30 49 rm -f $(TARGET) $(OBJS)
94f69966
JP
50
51dist:
52 git tag v$(VERSION)
53 git archive --format=tar --prefix="$(TARGET)-$(VERSION)/" v$(VERSION) | \
54 gzip > $(TARGET)-$(VERSION).tar.gz