Makefile: fix detecting the compiler
authorAntonio Ospite <ao2@ao2.it>
Thu, 22 Feb 2018 10:27:53 +0000 (11:27 +0100)
committerAntonio Ospite <ao2@ao2.it>
Thu, 22 Feb 2018 10:31:13 +0000 (11:31 +0100)
Rely on the compiler version, to behave "more correctly" in case CXX is
just c++.

Makefile

index 6bb3c15..4e316b9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,12 +23,14 @@ CXXFLAGS += -fno-common \
            -fstack-protector \
            --param=ssp-buffer-size=4
 
-ifneq ($(CXX),clang++)
+COMPILER = $(shell $(CXX) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc)
+
+ifeq ($(COMPILER), gcc)
   CXXFLAGS += -Wunsafe-loop-optimizations \
              -Wunused-but-set-variable
 endif
 
-ifeq ($(CXX),clang++)
+ifeq ($(COMPILER), clang)
   LDFLAGS += -Qunused-arguments
 endif