1From 95382246ddd889839633aa0da800a03936b93986 Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Sun, 31 Oct 2021 18:26:01 +0100
4Subject: [PATCH] add --disable-stack-protector option
5
6Allow the user to disable stack-protector as not all toolchains support
7this feature
8
9Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
10Upstream: https://github.com/fenrus75/powertop/pull/138
11---
12 configure.ac    | 4 ++++
13 src/Makefile.am | 5 ++++-
14 2 files changed, 8 insertions(+), 1 deletion(-)
15
16diff --git a/configure.ac b/configure.ac
17index 37c1304..69160d5 100644
18--- a/configure.ac
19+++ b/configure.ac
20@@ -43,6 +43,10 @@ AX_ADD_FORTIFY_SOURCE
21 AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
22 PKG_PROG_PKG_CONFIG
23
24+AC_ARG_ENABLE([stack-protector],
25+	AS_HELP_STRING([--disable-stack-protector], [Disable stack-protector]))
26+AM_CONDITIONAL([ENABLE_STACK_PROTECTOR], [test x$enable_stack_protector != xno])
27+
28 # Checks for libraries.
29 AX_PTHREAD([
30     LIBS="$PTHREAD_LIBS $LIBS"
31diff --git a/src/Makefile.am b/src/Makefile.am
32index 6b523f6..ca30d20 100644
33--- a/src/Makefile.am
34+++ b/src/Makefile.am
35@@ -138,13 +138,16 @@ powertop_CXXFLAGS = \
36 	-Wformat \
37 	-Wshadow \
38 	-fno-omit-frame-pointer \
39-	-fstack-protector \
40 	$(GLIB2_CFLAGS) \
41 	$(LIBNL_CFLAGS) \
42 	$(NCURSES_CFLAGS) \
43 	$(PCIUTILS_CFLAGS) \
44 	$(PTHREAD_CFLAGS)
45
46+if ENABLE_STACK_PROTECTOR
47+powertop_CXXFLAGS += \
48+	-fstack-protector
49+endif
50
51 powertop_CPPFLAGS = \
52 	-DLOCALEDIR=\"$(localedir)\" \
53--
542.33.0
55
56