diff --git a/Makefile b/Makefile index e26e72e..f1f860a 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,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. @@ -70,6 +81,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)\"