# call it only once.
cc-opt = $(shell set -e; if $(CC) $(1) -c -xc - -o /dev/null </dev/null >&0 2>&0; then echo "$(1)"; fi;)
+# Disable a warning when supported by the compiler. Don't put spaces around the
+# warning! And don't use cc-opt which doesn't always report an error until
+# another one is also returned.
+# Usage: CFLAGS += $(call cc-nowarn,warning). Eg: $(call cc-opt,format-truncation)
+cc-nowarn = $(shell set -e; if $(CC) -W$(1) -c -xc - -o /dev/null </dev/null >&0 2>&0; then echo "-Wno-$(1)"; fi;)
+
#### Installation options.
DESTDIR =
PREFIX = /usr/local
# to be sure we get the intended behavior.
SPEC_CFLAGS := -fno-strict-aliasing -Wdeclaration-after-statement
SPEC_CFLAGS += $(call cc-opt,-fwrapv)
-SPEC_CFLAGS += $(call cc-opt,-Wno-format-truncation)
-SPEC_CFLAGS += $(call cc-opt,-Wno-address-of-packed-member)
-SPEC_CFLAGS += $(call cc-opt,-Wno-null-dereference)
+SPEC_CFLAGS += $(call cc-nowarn,format-truncation)
+SPEC_CFLAGS += $(call cc-nowarn,address-of-packed-member)
+SPEC_CFLAGS += $(call cc-nowarn,null-dereference)
#### Memory usage tuning
# If small memory footprint is required, you can reduce the buffer size. There