summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2017-03-03 12:26:24 -0800
committerMike Frysinger <vapier@gentoo.org>2018-06-07 00:41:30 -0400
commit3361e7f62bccabc396b4e298cbb2ddebedb8855f (patch)
tree5f1a3d8c948f9fa3762f71e46c7eb392f17cce74
parentpaxelf: constify elf_findsecbyname (diff)
downloadpax-utils-3361e7f62bccabc396b4e298cbb2ddebedb8855f.tar.gz
pax-utils-3361e7f62bccabc396b4e298cbb2ddebedb8855f.tar.bz2
pax-utils-3361e7f62bccabc396b4e298cbb2ddebedb8855f.zip
build: support clang a bit better
Use the -Werror=unknown-warning-option option if available so clang will reject some of the extra -W flags we add ourselves.
-rw-r--r--Makefile10
1 files changed, 6 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 569e924..c906311 100644
--- a/Makefile
+++ b/Makefile
@@ -2,13 +2,15 @@
# Distributed under the terms of the GNU General Public License v2
####################################################################
-check_gcc = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
+check_compiler = \
+ $(shell if $(CC) $(WUNKNOWN) $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
then echo "$(1)"; else echo "$(2)"; fi)
-check_gcc_many = $(foreach flag,$(1),$(call check_gcc,$(flag)))
+check_compiler_many = $(foreach flag,$(1),$(call check_compiler,$(flag)))
####################################################################
# Avoid CC overhead when installing
ifneq ($(MAKECMDGOALS),install)
+WUNKNOWN := $(call check_compiler,-Werror=unknown-warning-option)
_WFLAGS := \
-Wdeclaration-after-statement \
-Wextra \
@@ -19,7 +21,7 @@ WFLAGS := -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
-Wmissing-declarations -Wmissing-prototypes -Wwrite-strings \
-Wbad-function-cast -Wnested-externs -Wcomment -Winline \
-Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
- $(call check_gcc_many,$(_WFLAGS))
+ $(call check_compiler_many,$(_WFLAGS))
endif
CFLAGS ?= -O2 -pipe
@@ -86,7 +88,7 @@ DEBUG_FLAGS = \
-fsanitize=leak \
-fsanitize=undefined
debug: clean
- $(MAKE) CFLAGS="$(CFLAGS) -g3 -ggdb $(call check_gcc_many,$(DEBUG_FLAGS))" all
+ $(MAKE) CFLAGS="$(CFLAGS) -g3 -ggdb $(call check_compiler_many,$(DEBUG_FLAGS))" all
@-chpax -permsx $(ELF_TARGETS)
@-paxctl -permsx $(ELF_TARGETS)