From ec04aa3ae87b895dbc674a7e0b78b670f73a2c22 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Wed, 27 Sep 2017 16:02:35 -0700 Subject: 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 Signed-off-by: Zhang Rui --- tools/thermal/tmon/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile index 3a961e998281..5777bc78173f 100644 --- a/tools/thermal/tmon/Makefile +++ b/tools/thermal/tmon/Makefile @@ -1,8 +1,13 @@ +# 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} -fstack-protector +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)\" -- cgit From c21568ffabed918882c61eada79146706bd94684 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Wed, 27 Sep 2017 16:02:36 -0700 Subject: tools/thermal: tmon: allow $(CC) to be defined externally It can be helpful, especially when using a build system, to set the C compiler externally. Signed-off-by: Markus Mayer Signed-off-by: Zhang Rui --- tools/thermal/tmon/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile index 5777bc78173f..581da716ea1c 100644 --- a/tools/thermal/tmon/Makefile +++ b/tools/thermal/tmon/Makefile @@ -8,7 +8,7 @@ WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit- CFLAGS+= -O1 ${WARNFLAGS} # Add "-fstack-protector" only if toolchain supports it. CFLAGS+= $(call cc-option,-fstack-protector) -CC=$(CROSS_COMPILE)gcc +CC?= $(CROSS_COMPILE)gcc CFLAGS+=-D VERSION=\"$(VERSION)\" LDFLAGS+= -- cgit From 501a5c71d1f754e44142af6cae59042a8c3b2a11 Mon Sep 17 00:00:00 2001 From: Markus Mayer Date: Wed, 27 Sep 2017 16:02:37 -0700 Subject: tools/thermal: tmon: use $(PKG_CONFIG) instead of hard-coding pkg-config To ease cross-compiling, make use of the $(PKG_CONFIG) variable rather than hard-coding calls to pkg-config. Signed-off-by: Markus Mayer Signed-off-by: Zhang Rui --- tools/thermal/tmon/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile index 581da716ea1c..1e11bd38a6b4 100644 --- a/tools/thermal/tmon/Makefile +++ b/tools/thermal/tmon/Makefile @@ -9,6 +9,7 @@ CFLAGS+= -O1 ${WARNFLAGS} # Add "-fstack-protector" only if toolchain supports it. CFLAGS+= $(call cc-option,-fstack-protector) CC?= $(CROSS_COMPILE)gcc +PKG_CONFIG?= pkg-config CFLAGS+=-D VERSION=\"$(VERSION)\" LDFLAGS+= @@ -23,12 +24,12 @@ 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) -CFLAGS += $(shell pkg-config --cflags $(STATIC) panelw ncursesw 2> /dev/null || \ - pkg-config --cflags $(STATIC) panel ncurses 2> /dev/null) +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 += -- cgit