diff options
author | Roy Marples <roy@marples.name> | 2008-02-20 10:34:11 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-02-20 10:34:11 +0000 |
commit | fabce3a51bd503f4275337e48c3f9ba275d31d6b (patch) | |
tree | d1088b8366034ed4c9394de24a37af7a9dad979f /mk | |
parent | 26b8d108672c7fbc84d6cd2c6f8d22695f3449a3 (diff) |
Sanify the default cc flags.
Diffstat (limited to 'mk')
-rw-r--r-- | mk/cc.mk | 29 |
1 files changed, 11 insertions, 18 deletions
@@ -1,30 +1,23 @@ # Copyright 2008 Roy Marples <roy@marples.name> # Setup some good default CFLAGS +CFLAGS?= -O2 -CFLAGS?= -O2 -pipe - +# Default to using the C99 standard CSTD?= c99 _CSTD_SH= if test -n "${CSTD}"; then echo "-std=${CSTD}"; else echo ""; fi _CSTD!= ${_CSTD_SH} CFLAGS+= ${_CSTD}$(shell ${_CSTD_SH}) -# GNU Make way of detecting gcc flags we can use -check_gcc=$(shell if ${CC} $(1) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ - then echo "$(1)"; else echo "$(2)"; fi) - -# pmake check for extra cflags -WEXTRA!= for x in -Wdeclaration-after-statement -Wsequence-point -Wextra; do \ - if ${CC} $$x -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ - then echo -n "$$x "; fi \ - done - -# Loads of nice flags to ensure our code is good -CFLAGS+= -pedantic \ - -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \ +# Try and use some good cc flags +_CC_FLAGS= -pedantic -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \ -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \ -Wbad-function-cast -Wnested-externs -Wcomment -Winline \ -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \ - $(call check_gcc, -Wdeclaration-after-statement) \ - $(call check_gcc, -Wsequence-point) \ - $(call check_gcc, -Wextra) ${WEXTRA} + -Wdeclaration-after-statement -Wsequence-point -Wextra +_CC_FLAGS_SH= for f in ${_CC_FLAGS}; do \ + if ${CC} $$f -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \ + then printf "%s" "$$f "; fi \ + done +_CC_FLAGS!= ${_CC_FLAGS_SH} +CFLAGS+= ${_CC_FLAGS}$(shell ${CC_FLAGS_SH}) |