diff mbox series

[kvm-unit-tests,4/4] Makefile: add "cxx-option" for C++ builds

Message ID 20191014192431.137719-5-morbo@google.com (mailing list archive)
State New, archived
Headers show
Series Patches for clang compilation | expand

Commit Message

Bill Wendling Oct. 14, 2019, 7:24 p.m. UTC
The C++ compiler may not support all of the same flags as the C
compiler. Add a separate test for these flags.

Signed-off-by: Bill Wendling <morbo@google.com>
---
 Makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 3ec0458..b9ae791 100644
--- a/Makefile
+++ b/Makefile
@@ -48,6 +48,8 @@  include $(SRCDIR)/$(TEST_DIR)/Makefile
 
 cc-option = $(shell if $(CC) -Werror $(1) -S -o /dev/null -xc /dev/null \
               > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+cxx-option = $(shell if $(CXX) -Werror $(1) -S -o /dev/null -xc++ /dev/null \
+              > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
 
 COMMON_CFLAGS += -g $(autodepend-flags)
 COMMON_CFLAGS += -Wall -Wwrite-strings -Wempty-body -Wuninitialized
@@ -68,13 +70,15 @@  COMMON_CFLAGS += $(fno_pic) $(no_pie)
 COMMON_CFLAGS += $(call cc-option, -Wno-frame-address, "")
 COMMON_CFLAGS += $(call cc-option, -Wclobbered, "")
 COMMON_CFLAGS += $(call cc-option, -Wunused-but-set-parameter, "")
-COMMON_CFLAGS += $(call cc-option, -Wmissing-parameter-type, "")
-COMMON_CFLAGS += $(call cc-option, -Wold-style-declaration, "")
 
 CFLAGS += $(COMMON_CFLAGS)
+CFLAGS += $(call cc-option, -Wmissing-parameter-type, "")
+CFLAGS += $(call cc-option, -Wold-style-declaration, "")
 CFLAGS += -Woverride-init -Wmissing-prototypes -Wstrict-prototypes
 
 CXXFLAGS += $(COMMON_CFLAGS)
+CXXFLAGS += $(call cxx-option, -Wmissing-parameter-type, "")
+CXXFLAGS += $(call cxx-option, -Wold-style-declaration, "")
 
 autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d