2014-05-07 13:02:22 +02:00
|
|
|
# Test if the input language was specified externally.
|
|
|
|
# Otherwise test if the compiler unterstands the "-std=gnu99" flag, and use it if so.
|
|
|
|
# Otherwise test if the compiler unterstands the "-std=c99" flag, and use it if so.
|
|
|
|
ifeq ($(filter -std=%,$(CFLAGS)),)
|
2014-09-28 14:56:29 +02:00
|
|
|
ifeq ($(shell $(CC) -std=gnu99 -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
|
|
|
|
CFLAGS += -std=gnu99
|
|
|
|
else
|
|
|
|
ifeq ($(shell $(CC) -std=c99 -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
|
|
|
|
CFLAGS += -std=c99
|
|
|
|
endif
|
|
|
|
endif
|
2014-05-07 13:02:22 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Add `-fno-delete-null-pointer-checks` flag iff the compiler supports it.
|
|
|
|
# GCC removes moves tests whether `x == NULL`, if previously `x` or even `x->y` was accessed.
|
|
|
|
# 0x0 might be a sane memory location for embedded systems, so the test must not be removed.
|
|
|
|
# Right now clang does not use the *delete-null-pointer* optimization, and does not understand the parameter.
|
|
|
|
# Related issues: #628, #664.
|
|
|
|
ifeq ($(shell $(CC) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
|
2014-09-28 14:56:29 +02:00
|
|
|
ifeq ($(shell LANG=C $(CC) -fno-delete-null-pointer-checks -E - 2>&1 1>/dev/null </dev/null | grep warning: | grep -- -fno-delete-null-pointer-checks),)
|
|
|
|
CFLAGS += -fno-delete-null-pointer-checks
|
|
|
|
|
|
|
|
ifneq ($(shell $(CXX) -fno-delete-null-pointer-checks -E - 2>/dev/null >/dev/null </dev/null ; echo $$?),0)
|
|
|
|
CXXUWFLAGS += -fno-delete-null-pointer-checks
|
|
|
|
else
|
|
|
|
ifneq ($(shell LANG=C $(CXX) -fno-delete-null-pointer-checks -E - 2>&1 1>/dev/null </dev/null | grep warning: | grep -- -fno-delete-null-pointer-checks),)
|
|
|
|
CXXUWFLAGS += -fno-delete-null-pointer-checks
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
2014-05-07 13:02:22 +02:00
|
|
|
endif
|
2014-05-07 13:02:46 +02:00
|
|
|
|
|
|
|
# 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)
|
2014-09-28 14:56:29 +02:00
|
|
|
# duplicated parameters don't hurt
|
|
|
|
CFLAGS += -Wstrict-prototypes -Werror=strict-prototypes -Wold-style-definition -Werror=old-style-definition
|
|
|
|
CXXUWFLAGS += -Wstrict-prototypes -Wold-style-definition
|
2014-05-07 13:02:46 +02:00
|
|
|
endif
|
2014-06-25 03:17:20 +02:00
|
|
|
|
|
|
|
# Unwanted flags for c++
|
2014-09-28 14:56:29 +02:00
|
|
|
CXXUWFLAGS += -std=%
|
2014-11-03 11:50:01 +01:00
|
|
|
|
|
|
|
ifeq ($(LTO),yes)
|
|
|
|
LTOFLAGS = -flto -ffat-lto-objects
|
|
|
|
CFLAGS += ${LTOFLAGS}
|
|
|
|
LINKFLAGS += ${LTOFLAGS}
|
|
|
|
endif
|
2015-01-23 19:24:55 +01:00
|
|
|
|
|
|
|
# Forbid common symbols to prevent accidental aliasing.
|
|
|
|
CFLAGS += -fno-common
|