Skip to content
Snippets Groups Projects
Unverified Commit 843cec5c authored by Joakim Nohlgård's avatar Joakim Nohlgård Committed by Gaëtan Harter
Browse files

makefiles/cflags.inc.mk: Use a template for CFLAGS testing

parent a71ef652
No related branches found
No related tags found
No related merge requests found
...@@ -25,21 +25,23 @@ ifeq ($(shell $(CC) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null ...@@ -25,21 +25,23 @@ 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
endif
# Unwanted flags for c++ # Unwanted flags for c++
CXXUWFLAGS += -std=% CXXUWFLAGS += -std=%
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment