Switch some annoying and wrang GCC warnings off.

This commit is contained in:
Yamagi Burmeister 2018-10-25 19:11:30 +02:00
parent 50a6255b0a
commit 4626e7a8d9
1 changed files with 27 additions and 0 deletions

View File

@ -43,6 +43,17 @@ else
ARCH := $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/')
endif
# Detect the compiler
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1)
COMPILER := clang
COMPILERVER := $(shell $(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
else ifeq ($(shell $(CC) -v 2>&1 | grep -c -E "(gcc version|gcc-Version)"), 1)
COMPILER := gcc
COMPILERVER := $(shell $(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/')
else
COMPILER := unknown
endif
# ----------
# Base CFLAGS.
@ -73,6 +84,22 @@ endif
# ----------
# Switch of some annoying warnings.
ifeq ($(COMPILER), clang)
# -Wno-missing-braces because otherwise clang complains
# about totally valid 'vec3_t bla = {0}' constructs.
CFLAGS += -Wno-missing-braces
else ifeq ($(COMPILER), gcc)
# GCC 8.0 or higher.
ifeq ($(shell test $(COMPILERVER) -ge 80000; echo $$?),0)
# -Wno-format-truncation and -Wno-format-overflow
# because GCC spams about 50 false positives.
CFLAGS += -Wno-format-truncation -Wno-format-overflow
endif
endif
# ----------
# Defines the operating system and architecture
CFLAGS += -DOSTYPE=\"$(OSTYPE)\" -DARCH=\"$(ARCH)\"