int0x21 / rpms / dlm

Forked from rpms/dlm 4 years ago
Clone
Blob Blame History Raw
From db875a3d07f9f6a633951ed886cec80b91efea43 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Tue, 2 Oct 2018 11:22:39 -0500
Subject: [PATCH] update makefile gcc flags

---
 dlm_controld/Makefile | 41 ++++++++++++++---------------------------
 dlm_tool/Makefile     | 44 ++++++++++++++++----------------------------
 fence/Makefile        | 46 +++++++++++++++++-----------------------------
 libdlm/Makefile       |  6 +++++-
 4 files changed, 52 insertions(+), 85 deletions(-)

diff --git a/dlm_controld/Makefile b/dlm_controld/Makefile
index cf556c9d72b8..85c2db12883a 100644
--- a/dlm_controld/Makefile
+++ b/dlm_controld/Makefile
@@ -31,35 +31,22 @@ BIN_SOURCE = action.c \
              rbtree.c
 LIB_SOURCE = lib.c
 
-BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-	-Wall \
-	-Wformat \
-	-Wformat-security \
-	-Wmissing-prototypes \
-	-Wnested-externs \
-	-Wpointer-arith \
-	-Wextra -Wshadow \
-	-Wcast-align \
-	-Wwrite-strings \
-	-Waggregate-return \
-	-Wstrict-prototypes \
-	-Winline \
-	-Wredundant-decls \
-	-Wno-sign-compare \
-	-Wno-unused-parameter \
-	-Wp,-D_FORTIFY_SOURCE=2 \
-	-fexceptions \
-	-fasynchronous-unwind-tables \
-	-fdiagnostics-show-option \
-
-BIN_CFLAGS += -fPIE -DPIE
+CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
+	-Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs \
+	-Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings \
+	-Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls \
+	-Wno-sign-compare -Wno-unused-parameter -Wp,-D_FORTIFY_SOURCE=2 \
+	-fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option \
+	-Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong \
+	-fstack-clash-protection -Wl,-z,now
+
+BIN_CFLAGS += $(CFLAGS) -fPIE -DPIE
 BIN_CFLAGS += -I../include -I../libdlm
+LIB_CFLAGS += $(CFLAGS) -fPIC
 
-BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
+BIN_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -pie
 BIN_LDFLAGS += -lpthread -lrt -lcpg -lcmap -lcfg -lquorum
-
-LIB_CFLAGS += $(BIN_CFLAGS)
-LIB_LDFLAGS += -Wl,-z,relro -pie
+LIB_LDFLAGS += $(LDFLAGS) -Wl,-z,relro -pie
 
 ifeq ($(USE_SD_NOTIFY),yes)
 	BIN_CFLAGS += $(shell pkg-config --cflags libsystemd) \
@@ -73,7 +60,7 @@ $(BIN_TARGET): $(BIN_SOURCE)
 	$(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L.
 
 $(LIB_TARGET): $(LIB_SOURCE)
-	$(CC) $^ $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -fPIC -o $@ -Wl,-soname=$(LIB_SMAJOR)
+	$(CC) $^ $(LIB_CFLAGS) $(LIB_LDFLAGS) -shared -o $@ -Wl,-soname=$(LIB_SMAJOR)
 	ln -sf $(LIB_TARGET) $(LIB_SO)
 	ln -sf $(LIB_TARGET) $(LIB_SMAJOR)
 
diff --git a/dlm_tool/Makefile b/dlm_tool/Makefile
index c16d8f537225..80d7725791f3 100644
--- a/dlm_tool/Makefile
+++ b/dlm_tool/Makefile
@@ -8,38 +8,26 @@ MAN_TARGET = dlm_tool.8
 
 BIN_SOURCE = main.c
 
-BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-	-Wall \
-	-Wformat \
-	-Wformat-security \
-	-Wmissing-prototypes \
-	-Wnested-externs \
-	-Wpointer-arith \
-	-Wextra -Wshadow \
-	-Wcast-align \
-	-Wwrite-strings \
-	-Waggregate-return \
-	-Wstrict-prototypes \
-	-Winline \
-	-Wredundant-decls \
-	-Wno-sign-compare \
-	-Wno-unused-parameter \
-	-Wp,-D_FORTIFY_SOURCE=2 \
-	-fexceptions \
-	-fasynchronous-unwind-tables \
-	-fdiagnostics-show-option \
-
-BIN_CFLAGS += -fPIE -DPIE
-BIN_CFLAGS += -I../include -I../libdlm -I../dlm_controld
-
-BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
-BIN_LDFLAGS += -L../libdlm -L../dlm_controld
-BIN_LDFLAGS += -lpthread -ldlm -ldlmcontrol
+CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
+	-Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs \
+	-Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings \
+	-Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls \
+	-Wno-sign-compare -Wno-unused-parameter -Wp,-D_FORTIFY_SOURCE=2 \
+	-fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option \
+	-Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong \
+	-fstack-clash-protection -Wl,-z,now
+
+CFLAGS += -fPIE -DPIE
+CFLAGS += -I../include -I../libdlm -I../dlm_controld
+
+LDFLAGS += -Wl,-z,relro -pie
+LDFLAGS += -L../libdlm -L../dlm_controld
+LDFLAGS += -lpthread -ldlm -ldlmcontrol
 
 all: $(BIN_TARGET)
 
 $(BIN_TARGET): $(BIN_SOURCE)
-	$(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@
+	$(CC) $(BIN_SOURCE) $(CFLAGS) $(LDFLAGS) -o $@
 
 clean:
 	rm -f *.o *.so *.so.* $(BIN_TARGET)
diff --git a/fence/Makefile b/fence/Makefile
index 77bf0fd15be8..b927879eb141 100644
--- a/fence/Makefile
+++ b/fence/Makefile
@@ -8,39 +8,27 @@ MAN_TARGET = dlm_stonith.8
 
 BIN_SOURCE = stonith_helper.c
 
-BIN_CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
-	-Wall \
-	-Wformat \
-	-Wformat-security \
-	-Wmissing-prototypes \
-	-Wnested-externs \
-	-Wpointer-arith \
-	-Wextra -Wshadow \
-	-Wcast-align \
-	-Wwrite-strings \
-	-Waggregate-return \
-	-Wstrict-prototypes \
-	-Winline \
-	-Wredundant-decls \
-	-Wno-sign-compare \
-	-Wno-unused-parameter \
-	-Wp,-D_FORTIFY_SOURCE=2 \
-	-fexceptions \
-	-fasynchronous-unwind-tables \
-	-fdiagnostics-show-option \
-
-BIN_CFLAGS += -fPIE -DPIE
-BIN_CFLAGS += `xml2-config --cflags`
-BIN_CFLAGS += -I../include
-
-BIN_LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
-BIN_LDFLAGS += `xml2-config --libs`
-BIN_LDFLAGS += -ldl
+CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
+	-Wall -Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs \
+	-Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings \
+	-Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls \
+	-Wno-sign-compare -Wno-unused-parameter -Wp,-D_FORTIFY_SOURCE=2 \
+	-fexceptions -fasynchronous-unwind-tables -fdiagnostics-show-option \
+	-Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong \
+	-fstack-clash-protection -Wl,-z,now
+
+CFLAGS += -fPIE -DPIE
+CFLAGS += `xml2-config --cflags`
+CFLAGS += -I../include
+
+LDFLAGS += -Wl,-z,relro -pie
+LDFLAGS += `xml2-config --libs`
+LDFLAGS += -ldl
 
 all: $(BIN_TARGET)
 
 $(BIN_TARGET): $(BIN_SOURCE)
-	$(CC) $(BIN_SOURCE) $(BIN_CFLAGS) $(BIN_LDFLAGS) -o $@ -L.
+	$(CC) $(BIN_SOURCE) $(CFLAGS) $(LDFLAGS) -o $@ -L.
 
 clean:
 	rm -f *.o *.so *.so.* $(BIN_TARGET)
diff --git a/libdlm/Makefile b/libdlm/Makefile
index 336c22e7edb4..ab32761912b3 100644
--- a/libdlm/Makefile
+++ b/libdlm/Makefile
@@ -72,10 +72,14 @@ CFLAGS += -D_GNU_SOURCE -O2 -ggdb \
 	-Wno-sign-compare \
 	-Wno-unused-parameter \
 	-Wp,-D_FORTIFY_SOURCE=2 \
+	-Wp,-D_GLIBCXX_ASSERTIONS \
+	-fstack-protector-strong \
+	-fstack-clash-protection \
 	-fexceptions \
 	-fasynchronous-unwind-tables \
 	-fdiagnostics-show-option \
-	-fPIC
+	-fPIC \
+	-Wl,-z,now
 
 LIB_CFLAGS += $(CFLAGS) -D_REENTRANT
 LLT_CFLAGS += $(CFLAGS)
-- 
2.7.5