From: Michael Shigorin mike@altlinux.org
This commit started with adding the test for checking for -fstack-clash-protection before use (not available before gcc8, added with 0533006b4d36e8699ea51036d8914c22e46fae3f unconditionally); should help cases like the one mentioned in commit a904a3de2997bc7ce55b6cb3647d5ec347f0a2fa as well as myself with lcc/e2k.
The CFLAGS specification and handling duplication didn't look all that well so I chose to reimplement the whole set of Makefiles into a proper recursive form with a shared one to include; should be easier to maintain overall.
Signed-off-by: Michael Shigorin mike@altlinux.org Signed-off-by: Nir Soffer nsoffer@redhat.com Tested-by: Nir Soffer nsoffer@redhat.com ---
I rebased and tested on top of: https://github.com/nirs/sanlock/commit/bb0211a8a0cff302b09a5b419f30594d49888...
Makefile | 26 +++++++++++++++++--------- common.mk | 31 +++++++++++++++++++++++++++++++ reset/Makefile | 29 ++--------------------------- src/Makefile | 29 ++--------------------------- wdmd/Makefile | 29 ++--------------------------- 5 files changed, 54 insertions(+), 90 deletions(-) create mode 100644 common.mk
diff --git a/Makefile b/Makefile index 8b41526..36587e0 100644 --- a/Makefile +++ b/Makefile @@ -8,19 +8,27 @@ release := 0 endif
distname := sanlock-$(version) tarball := $(distname).tar.gz
-all: - $(MAKE) -C wdmd - $(MAKE) -C src - $(MAKE) -C python - -clean: - $(MAKE) -C wdmd clean - $(MAKE) -C src clean - $(MAKE) -C python clean +SUBDIRS = wdmd src python reset + +.PHONY: all $(SUBDIRS) clean install + +all: $(SUBDIRS) + +$(SUBDIRS): + $(MAKE) -C $@ + +src: wdmd + +python reset: src + +clean install: + for dir in $(SUBDIRS); do \ + $(MAKE) -C $$dir $@; \ + done
dist: spec rm -f $(tarball) git archive --prefix=$(distname)/ HEAD > $(distname).tar tar rf $(distname).tar --transform="s|^|$(distname)/&|" sanlock.spec diff --git a/common.mk b/common.mk new file mode 100644 index 0000000..3221393 --- /dev/null +++ b/common.mk @@ -0,0 +1,31 @@ +export CC ?= cc + +check = $(shell echo "int main() { return 0; }" \ + | $(CC) $(1) -xc - >&/dev/null && echo $(1) ||:) + +export 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 \ + -Wno-strict-overflow \ + -fexceptions \ + -fasynchronous-unwind-tables \ + -fdiagnostics-show-option \ + -Wp,-D_GLIBCXX_ASSERTIONS \ + -fstack-protector-strong \ + $(check -fstack-clash-protection) \ + -Wl,-z,now diff --git a/reset/Makefile b/reset/Makefile index 5f5c425..004dbb6 100644 --- a/reset/Makefile +++ b/reset/Makefile @@ -1,38 +1,13 @@ +include ../common.mk + TARGET1 = sanlk-resetd TARGET2 = sanlk-reset
SOURCE1 = sanlk_resetd.c SOURCE2 = sanlk_reset.c
-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 \ - -Wno-strict-overflow \ - -fexceptions \ - -fasynchronous-unwind-tables \ - -fdiagnostics-show-option \ - -Wp,-D_GLIBCXX_ASSERTIONS \ - -fstack-protector-strong \ - -fstack-clash-protection \ - -Wl,-z,now - VER=$(shell cat ../VERSION) CFLAGS += -DVERSION="$(VER)" -I../src -I../wdmd
CFLAGS += -fPIE -DPIE
diff --git a/src/Makefile b/src/Makefile index 623ea3a..533dd79 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,10 +2,12 @@ # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions # of the GNU General Public License v2 or (at your option) any later version.
+include ../common.mk + CMD_TARGET = sanlock HEADER_TARGET = sanlock.h sanlock_rv.h sanlock_resource.h sanlock_admin.h sanlock_direct.h MAN_TARGET = sanlock.8
SOMAJOR=1 @@ -65,37 +67,10 @@ LIB_CLIENT_SOURCE = \ env.c
LIBPC_ENTIRE_SOURCE = libsanlock.pc.in LIBPC_CLIENT_SOURCE = libsanlock_client.pc.in
-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 \ - -Wno-strict-overflow \ - -fexceptions \ - -fasynchronous-unwind-tables \ - -fdiagnostics-show-option \ - -Wp,-D_GLIBCXX_ASSERTIONS \ - -fstack-protector-strong \ - -fstack-clash-protection \ - -Wl,-z,now - VER=$(shell cat ../VERSION) CFLAGS += -DVERSION="$(VER)"
CMD_CFLAGS = $(CFLAGS) -fPIE -DPIE LIB_ENTIRE_CFLAGS = $(CFLAGS) -fPIC diff --git a/wdmd/Makefile b/wdmd/Makefile index 74b04e2..5849efc 100644 --- a/wdmd/Makefile +++ b/wdmd/Makefile @@ -2,10 +2,12 @@ # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions # of the GNU General Public License v2 or (at your option) any later version.
+include ../common.mk + CMD_TARGET = wdmd LIB_TARGET = libwdmd HEADER_TARGET = wdmd.h MAN_TARGET = wdmd.8 TEST_TARGET = wdmd_client @@ -18,37 +20,10 @@ CMD_SOURCE = main.c wdmd_sock.c
LIB_SOURCE = client.c wdmd_sock.c
TEST_SOURCE = wdmd_client.c
-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 \ - -Wno-strict-overflow \ - -fexceptions \ - -fasynchronous-unwind-tables \ - -fdiagnostics-show-option \ - -Wp,-D_GLIBCXX_ASSERTIONS \ - -fstack-protector-strong \ - -fstack-clash-protection \ - -Wl,-z,now - VER=$(shell cat ../VERSION) CFLAGS += -DVERSION="$(VER)"
CMD_CFLAGS = $(CFLAGS) -fPIE -DPIE LIB_CFLAGS = $(CFLAGS) -fPIC
sanlock-devel@lists.fedorahosted.org