Skip to content
Snippets Groups Projects
Unverified Commit 9f937457 authored by Martine Lenders's avatar Martine Lenders Committed by GitHub
Browse files

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

makefiles/cflags.inc.mk: Use a template for CFLAGS testing
parents 063c54ac 843cec5c
No related branches found
No related tags found
No related merge requests found
...@@ -25,28 +25,27 @@ ifeq ($(shell $(CC) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null ...@@ -25,28 +25,27 @@ ifeq ($(shell $(CC) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null
endif endif
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 # Use colored compiler output if the compiler supports this and if this is not
# disabled by the user # disabled by the user
ifeq ($(CC_NOCOLOR),0) ifeq ($(CC_NOCOLOR),0)
ifeq ($(shell $(CC) -fdiagnostics-color -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0) $(eval $(call cflags_test_and_add,-fdiagnostics-color))
CFLAGS += -fdiagnostics-color
endif
endif endif
# Fast-out on old style function definitions. # Fast-out on old style function definitions.
# They cause unreadable error compiler errors on missing semicolons. # They cause unreadable error compiler errors on missing semicolons.
# Worse yet they hide errors by accepting wildcard argument types. # 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) $(foreach flag,-Wstrict-prototypes -Wold-style-definition,$(eval $(call cflags_test_and_add,$(flag))))
# 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
# Unwanted flags for c++ # Unwanted flags for c++
CXXUWFLAGS += -std=% CXXUWFLAGS += -std=%
CXXUWFLAGS += -Wstrict-prototypes -Wold-style-definition
ifeq ($(LTO),1) ifeq ($(LTO),1)
$(warning Building with Link-Time-Optimizations is currently an experimental feature. Expect broken binaries.) $(warning Building with Link-Time-Optimizations is currently an experimental feature. Expect broken binaries.)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment