linux/tools/thermal/tmon/Makefile
Markus Mayer ec04aa3ae8 tools/thermal: tmon: use "-fstack-protector" only if supported
Most, but not all, toolchains support the "-fstack-protector" flag. We
check if the compiler supports the flag before using it. This allows
tmon to be compiled for more environments.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
2017-10-18 09:59:30 +08:00

57 lines
1.6 KiB
Makefile

# We need this for the "cc-option" macro.
include ../../../scripts/Kbuild.include
VERSION = 1.0
BINDIR=usr/bin
WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int
CFLAGS+= -O1 ${WARNFLAGS}
# Add "-fstack-protector" only if toolchain supports it.
CFLAGS+= $(call cc-option,-fstack-protector)
CC=$(CROSS_COMPILE)gcc
CFLAGS+=-D VERSION=\"$(VERSION)\"
LDFLAGS+=
TARGET=tmon
INSTALL_PROGRAM=install -m 755 -p
DEL_FILE=rm -f
# 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)
CFLAGS += $(shell pkg-config --cflags $(STATIC) panelw ncursesw 2> /dev/null || \
pkg-config --cflags $(STATIC) panel ncurses 2> /dev/null)
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)"
uninstall:
$(DEL_FILE) "$(INSTALL_ROOT)/$(BINDIR)/$(TARGET)"
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