1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

Merge pull request #9358 from gebart/pr/cflags-cleanup

makefiles/cflags.inc.mk: Use a template for CFLAGS testing
This commit is contained in:
Martine Lenders 2018-07-18 14:11:49 +02:00 committed by GitHub
commit 9f93745734
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,28 +25,27 @@ ifeq ($(shell $(CC) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null
endif
endif
# Template for testing a compiler flag and adding it to CFLAGS (errors usually
# happens when using older toolchains which do not support the given flags)
define cflags_test_and_add
ifeq ($(shell $(CC) $(1) -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
CFLAGS += $(1)
endif
endef
# Use colored compiler output if the compiler supports this and if this is not
# disabled by the user
ifeq ($(CC_NOCOLOR),0)
ifeq ($(shell $(CC) -fdiagnostics-color -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
CFLAGS += -fdiagnostics-color
endif
$(eval $(call cflags_test_and_add,-fdiagnostics-color))
endif
# Fast-out on old style function definitions.
# They cause unreadable error compiler errors on missing semicolons.
# Worse yet they hide errors by accepting wildcard argument types.
ifeq ($(shell $(CC) -Wstrict-prototypes -Werror=strict-prototypes -Wold-style-definition -Werror=old-style-definition -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
# duplicated parameters don't hurt
CFLAGS += -Wstrict-prototypes -Wold-style-definition
CXXUWFLAGS += -Wstrict-prototypes -Wold-style-definition
ifeq ($(WERROR),1)
CFLAGS += -Werror=strict-prototypes -Werror=old-style-definition
endif
endif
$(foreach flag,-Wstrict-prototypes -Wold-style-definition,$(eval $(call cflags_test_and_add,$(flag))))
# Unwanted flags for c++
CXXUWFLAGS += -std=%
CXXUWFLAGS += -Wstrict-prototypes -Wold-style-definition
ifeq ($(LTO),1)
$(warning Building with Link-Time-Optimizations is currently an experimental feature. Expect broken binaries.)